Re: Scripting Bridge usage, iPhoto example
Re: Scripting Bridge usage, iPhoto example
- Subject: Re: Scripting Bridge usage, iPhoto example
- From: has <email@hidden>
- Date: Sat, 15 May 2010 18:13:55 +0100
Jeffrey J. Early wrote:
> [...] I'm puzzled now why this fails,
>
> tell application "iPhoto"
> set myPhoto to the last item of (every photo whose name is "__iPhotoTest")
> tell myPhoto
> assign keyword string "Vacation"
> end tell
> end tell
>
> but this does not,
>
> tell application "iPhoto"
> set myPhoto to the last item of (every photo whose name is "__iPhotoTest")
> tell myPhoto
> reverse geocode
> end tell
> end tell
>
> ??? I don't see any distinction in the iPhoto dictionary that would suggest one would work and other wouldn't. I guess the whole thing is a little bizarre to me -- I can't really determine which objects respond to which actions just by looking at the Applescript dictionary.
Couple of issues:
1. Application dictionaries normally don't provide all of the detail you need in order to script an application effectively. This is partly due to inherent shortcomings in the dictionary format; partly due to application developers not knowing and/or bothering to provide all of the information they could. As a rule, you start with the dictionary, then work out the remaining details by reading supplementary documentation (if any exists), studying existing scripts, educated guesswork and trial-and-error experimentation. Not an ideal process, but historically what we're stuck with.
2. iPhoto's scripting interface is notoriously badly designed. Technically it works, but it breaks most of the Scripting Interface Guidelines, and there is little rhyme or reason in how the various commands operate or are documented. The 'assign keyword' command's description states that it manipulates the objects currently selected in the GUI, but it appears to take a reference to the objects to manipulate as its direct parameter. From testing, it turns out that the description is correct and the presence of the direct parameter is wrong. That said, it's rotten design on at least three different levels: 1. Model objects should be manipulated directly from the scripting interface, not from the scripting interface via the GUI (i.e. it _should_ use the direct parameter, not the current GUI selection); 2. the keyword to apply must be specified by a string (it ought to be a reference to a 'keyword' element of the main application object); 3. it's a non-standard command for performing a standard operation (there is already a 'add' command for performing this type of operation, e.g. compare adding people to groups in Address Book).
> I'm wanting to use the action "assign keyword" on a photo, but maybe that's just not possible? I'm forced to actually select a photo first, then tell the *application* to "assign keyword"?
Yes. Or, presumably, you can select multiple photos at once. You should be able to do it from your script by assigning a list of photo references to the application's 'selection' property. Like I say, it's really awful design, but Apple applications are notoriously uneven in the quality of their scripting interfaces. If it bothers you, file some Radar reports on it (I have no idea if this will have any practical effect, but if enough AS users did this, application developers might start paying it a bit more notice).
HTH
has
--
Control AppleScriptable applications from Python, Ruby and ObjC:
http://appscript.sourceforge.net
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden