Apple Photo (media) Picker
todd at geistinteractive.com
Fri Dec 9 11:58:12 EST 2011
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.
On Fri, Dec 9, 2011 at 8:25 AM, Ken Ray <kray at sonsothunder.com> 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
> 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
> 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
> put the result
> end mouseUp
> on ChoosePicture
> put 30000 into tTimeout
> put specialFolderPath("documents") & "/picturepath.txt" into tPicPathFile
> put specialFolderPath("desktop") & "/Choose Picture.app" into
> 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
> 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
> 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
> 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…
> Ken Ray
> Sons of Thunder Software, Inc.
> Email: kray at sonsothunder.com
> Web Site: http://www.sonsothunder.com/
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
More information about the Use-livecode