GUI Scripting under Panther
GUI Scripting under Panther
- Subject: GUI Scripting under Panther
- From: Bill Cheeseman <email@hidden>
- Date: Sun, 26 Oct 2003 20:28:09 -0500
As many of you have undoubtedly discovered in the last day or two, GUI
Scripting has some powerful new features under Panther. I haven't had time
yet to read all of the new documentation on the Apple site, so some of what
I have to say here may repeat information newly posted by Apple at
<
http://www.apple.com/applescript/uiscripting/>.
I'm sure Paul Berkowitz won't mind my repeating some of what he asked me
today:
on 03-10-26 4:21 PM, Paul Berkowitz ... wrote:
>
Using v1.1.1 [of PreFab UI Browser] in Panther, I
>
see that the menus of Entourage are referred to as
>
>
AXMenuBarItem "Format" of menu bar 1
>
>
etc. But using that format in a script errors. However, using
>
>
UI element "Format" of menu bar 1
>
>
works fine. What's an AXMenuBarItem , and should it maybe be something else?
PreFab UI Browser 1.2 will be released within the next few days, with many
improvements to work with new features of GUI Scripting in Panther. In the
meantime, if you're using UI Browser 1.1.1, change "AXMenuBarItem" to "menu
bar item" wherever it appears in a script generated by UI Browser, to gain
Panther compatibility. Or simply remove that piece of the menu reference to
make the script work correctly both under Jaguar and Panther. See the
examples below.
In Panther, the accessibility API has undergone some changes. One of them is
that the standard menu bar hierarchy is now menu bar 1 > menu bar item 1 >
menu 1 > menu item 1 > menu 1, etc. "AXMenuBarItem" is a new object inserted
in the hierarchy below AXMenuBar, partly to make the accessibility API
correspond to the actual structure that has always existed in the underlying
system, but mostly to make the pattern of item > menu, item > menu, item >
menu repeat consistently from top to bottom (with a lone menu, the menu bar,
at the top).
The basic idea, which has always existed in the underlying system, is this:
(1) the menu bar is actually a menu (that is, an object that can hold a
collection of menu items; (2) each of the menus you see in the menubar
(e.g., File, Edit, View) actually represents two objects, a menu item (or a
"menu bar item," in the new GUI Scripting terminology) and, if there are
submenus, a menu of the same name (again, an object that can hold a
collection of menu items); and (3) each of the menu items you see when you
open a menu in the menu bar (or when you open any hierarchical submenu) is
actually two objects, a menu item, and, if there are submenus, a menu of the
same name -- and so on as far as the hierarchy descends.
GUI Scripting in Panther recognizes both the old and the new way of
scripting this hierarchy, to preserve backward compatibility for the benefit
of old scripts. As a result, the two pairs of scripts below function the
same under Panther (e.g., returning "About This Mac" if you target the
Finder), while only the last pair will work if the script is run under
Jaguar:
get name of menu item 1 of menu 1 of menu bar item 1 of menu bar 1
get name of menu item "About This Mac" of menu "Apple" of menu bar item
"Apple" of menu bar 1
get name of menu item 1 of menu 1 of menu bar 1
get name of menu item "About This Mac" of menu "Apple" of menu bar 1
"UI element" works in place of "menu bar item" in Panther, presumably
because it is the superclass for any UI element.
There is a lot more to learn about GUI Scripting in Panther, so I'll try to
post some more tips as time permits.
--
Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
http://www.quecheesoftware.com
The AppleScript Sourcebook -
http://www.AppleScriptSourcebook.com
Vermont Recipes -
http://www.stepwise.com/Articles/VermontRecipes
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.