Re: Photoshop CS2 and GUI Scripting
Re: Photoshop CS2 and GUI Scripting
- Subject: Re: Photoshop CS2 and GUI Scripting
- From: Bill Cheeseman <email@hidden>
- Date: Mon, 22 May 2006 16:35:19 -0400
- Thread-topic: Photoshop CS2 and GUI Scripting
on 2006-05-22 3:08 PM, kai at email@hidden wrote:
> On 22 May 2006, at 10:04, Bill Cheeseman wrote:
>
>> on 2006-05-21 8:54 PM, Irwin Poche at email@hidden wrote:
>>
>>> tell application process "Photoshop" to set y to name of menu item
>>> 7 of menu 1
>>> of menu bar item "View" of menu bar 1
>>> --should be "Zoom In"
>>
>> There is no "name" property of a menu item. It should be 'set y to
>> title of
>> menu item....'
>
> That would certainly explain Irwin's
> "NSReceiverEvaluationScriptError: 4" error, Bill.
>
> Were you referring to Photoshop CS2 specifically? I ask because most
> application processes I've tested appear to have both a title and a
> name property (usually with the same value). For example, a quick
> poll of a few processes gives me this:
Well, ahem, that's a very interesting question.
I was wrong. The 'name' and 'title' forms work interchangeably, at least in
this case.
There's a story behind this. The accessibility API, on which GUI Scripting
is based, does not implement an AXName attribute, but only an AXTitle
attribute. My PreFab UI Browser application takes the accessibility API
pretty seriously, because UI Browser is a tool for developers of
accessibility-based applications as much as it is a GUI Scripting
AppleScript tool. UI Browser's Attributes drawer therefore lists a 'title'
attribute for menu items, but not a 'name' attribute. That's what I glanced
at when I fired off my too-quick post, because I'm deep into coding UI
Browser 2.0 and I am focused on the accessibility side of it at the moment,
not the AppleScript side.
I forgot -- as I once knew from the horse's mouth -- that the GUI Scripting
engineer at Apple who implemented GUI Scripting thought it made sense to
have a 'name' property of the 'UI element' class in the System Events
dictionary, for the perfectly good reason that it is consistent with the
AppleScript tradition whereby named objects generally have, well, a 'name'
property. In fact, it was for that very reason that I wrote UI Browser so
that it generates a script to return the 'name' property of a UI element,
not a 'title' property.
The System Events dictionary also has a 'title' property, of course, since
the GUI Scripting is based on the accessibility API and that API has a
'title' attribute. The System Events dictionary describes them differently,
and I have no idea whether the difference has any practical impact:
'name' - the name of the UI Element, which identifies it within its
container
'title' - the title of the UI element as it appears on the screen
If someone could explain the technical difference to me, I would appreciate
it. Perhaps it has to do with localization. I'm not familiar enough with the
use of AppleScript under other language systems to know whether AppleScript
needs menu names in localized form, or whether the localized name is useful
for generating dialog text in localized form.
So, mea culpa, the use of the 'name' property by the original poster was NOT
the problem with his script.
What was wrong with the OP's script? It works perfectly well for me now,
using either 'name' or 'title'. It didn't work at first. Then I made one
change, and it started working:
I added a statement at the beginning to 'activate application "Adobe
Photoshop CS2.app"'. I don't know whether it was the 'activate' part or the
"app" name extension that made the difference. Of course, the "app" name
extension disappeared as soon as I compiled the script, but I guess it's
there invisibly, anyway.
--
Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
http://www.quecheesoftware.com
PreFab Software - http://www.prefab.com/scripting.html
The AppleScript Sourcebook - http://www.AppleScriptSourcebook.com
Vermont Recipes - http://www.stepwise.com/Articles/VermontRecipes
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden