Apple Photo (media) Picker

Graham Samuel livfoss at
Fri Dec 9 17:24:11 EST 2011

This is just a quick thank you to Ken Ray, and also to Todd Geist for his added note on this. I will get it going in my own environment soon. Being English, I don't often use the word "awesome" but it seems an appropriate response in this case.


On Fri, 9 Dec 2011 10:25:28 -0600,  Ken Ray <kray at> wrote:

> Here's what you do (I tested this):
> In Automator:
> 1) Start a new workflow and add two actions: "Ask for Photos" (this is in the 'Photos' category under 'Library' in the left column) and "New Text File" (this is in the 'Text' category). 
> 2) For "Ask for Photos", you can either leave it alone or uncheck "Allow multiple selection" (if you don't want the user to do that).
> 3) For "New Text File", set these settings (the rest you can just leave as defaults):
> 	Save as:  picturepath.txt
>        Where:   Documents            [x] Replacing existing files
> 4) Save the workflow as an application (you can pick from the 'FIle Format' popup menu at the bottom of the 'save as' dialog) named "Choose Picture". 
> NOTE: Save it to your desktop for now so the following LC script will work without modification.
> In LiveCode, create a button and put this script in it:
> on mouseUp
>  ChoosePicture
>  put the result
> end mouseUp
> on ChoosePicture
>  put 30000 into tTimeout
>  put specialFolderPath("documents") & "/picturepath.txt" into tPicPathFile
>  put specialFolderPath("desktop") & "/Choose" into tChoosePicApp
>  if there is a file tPicPathFile then delete file tPicPathFile
>  launch tChoosePicApp
>  put the milliseconds into tMS
>  put true into tTimedout
>  repeat until ((the milliseconds - tMS) >= tTimeout)
>    wait 100 milliseconds with messages
>    if there is a file tPicPathFile then
>      put url ("file:" & tPicPathFile) into tPicPath
>      delete file tPicPathFile
>      put false into tTimedOut
>      exit repeat
>    end if
>  end repeat
>  if not(tTimedOut) then
>    if tPicPath = "" then return "Cancel"
>    return tPicPath
>  else
>    return "timeout"
>  end if
> end ChoosePicture
> Now click the button and test it out? you should get back in "the result" either the path to the selected picture, the word "Cancel" (if they chose to click the Cancel button), or the word "timeout" if for some reason it couldn't get the file that is supposed to be created by the Choose Picture app.
> A couple of caveats/notes:
> 1) AFAIK there's no way to call the "Ask for Photos" palette from AppleScript directly, so that's the reason for the Automator solution.
> 2) When the "Ask for Photos" palette is open, the Automator "gear" icon is shown in the Mac menu bar (although there's nothing the user can do with it).
> 3) Feel free to change the paths to where you want to write the file, how it's named, etc? you get the idea on how this works?

and Todd Geist also wrote:
> Hello,
> This way works too.
> First create the automate as Ken described and save it somewhere. In this
> case I saved it on y desktop.
> then in LC do the following
> get shell ("automator '/Users/todd/Desktop/test.workflow'")
> put value(line 2 of it)
> That should do it.

More information about the Use-livecode mailing list