Thanks for the most excellent tutorial. It has been extremely helpful, and quite an eye-opener. AppleScript is beginning to grow on me as it's power is really beginning to hit home. Thanks for the links.
On a side note, would you recommend that writing AppleScript then converting it to Scripting Bridge is a good development path vs. just keeping things in AppleScript? Is it worth the extra effort in other words for GUI scripting? Are the performance gains (if any) worth it?
Oddly, I had a look for /System/Library/Frameworks/ApplicationServices.framework/Frameworks/HIServices.framework/Resources/English.lproj/ActionDescription.strings but it doesn't seem to exist on my system. There is only an InfoPlist.strings file in the final English.lproj folder (running 10.5.5).
I know this is a bit off-topic, but If I can indulge your attention a little further, how about accessing the context (control-click) popup menu for an album in iPhoto? The documentation seems to be a little sparse, but I'm thinking perhaps 'AXShowMenu' might work in some incantation. Or perhaps some combination of keypress (control) and perform click over the appropriate album?
Thoughts?
BTW, your iPhoto keywords adder worked like a charm for the latest iPhoto 7.1.5.
Best,
Dalmazio
Message: 3
Date: Wed, 10 Dec 2008 06:52:46 -0500
From: Bill Cheeseman <email@hidden>
Subject: Re: How to add keywords to photos in iPhoto?
To: AppleScript-Users Mail <email@hidden>
Message-ID: <C56517BE.77651%email@hidden">C56517BE.77651%email@hidden>
Content-Type: text/plain; charset="US-ASCII"
on 2008-12-10 2:40 AM, Dalmazio Brisinda at email@hidden wrote:
Where do you find the information for the line below when creating new iPhoto
keywords and the textfield is highlighted waiting for user input?
perform action "AXRaise" of front window
And what does this line actually do? Is it like a set focus? If I tried to
keystroke xxxx without this line and I just get a series of beeps. As if the
textfield does not have focus.
The 'perform' command and the 'action' object on which it acts are defined
in the "Processes Suite" of the System Events terminology dictionary. The
System Events application is located in /System/Library/CoreServices. If you
look there, you'll see that an 'action' object has two properties, 'name'
and 'description'. The legal 'name' property values, such as "AXRaise", are
not listed in the dictionary.
The actions recognized by GUI Scripting are defined in Apple's accessibility
API for developers. There are only 9 of them. If you look deeply into the
system frameworks on your Mac, here, you can see all of the actions:
/System/Library/Frameworks/ApplicationServices.framework/Frameworks/HIServi
ces.framework/Resources/English.lproj/ActionDescription.strings
To save you the trouble of looking, they are:
/* accessibility action description*/
"AXPress" = "press";
"AXIncrement" = "increment";
"AXDecrement" = "decrement";
"AXConfirm" = "confirm";
"AXAccept" = "accept";
"AXPick" = "pick";
"AXCancel" = "cancel";
"AXRaise" = "raise";
"AXShowMenu" = "show menu";
[...]