Re: menu bar 1 in 10.8?
Re: menu bar 1 in 10.8?
- Subject: Re: menu bar 1 in 10.8?
- From: LuKreme <email@hidden>
- Date: Thu, 27 Jun 2013 14:13:16 -0600
On 27 Jun 2013, at 07:54 , Bill Cheeseman <email@hidden> wrote:
> 1. Use GUI Scripting. It's tedious, but it works. For example, this script returns all the children of the Finder application when one Finder window is open:
That is what I tried to do with the menus
get name of menu bar items of menu bar 1
=> {"Apple", "Mail", "File", "Edit", "View", "Mailbox", "Message", "Format", "Window", "Help"}
And then I tried to get the items in "File" but you can't get them, you have to change the syntax AND add "menu 1". As far as I can tell, there is no way to use applescript to 'discover' this syntax.
get name of menu items of menu 1 of menu bar item "File" of menu bar 1
(note: it's not "get name of menu bar items" but "get name of menu items", and you can't get them for menu bar item "File", you have to get them from menu 1 of menu bar item "File"). This seems unnecessarily difficult, but I guess since it all happens with point and clicks in Xcode, Apple has no motivation to make this easier in Applescript?
> 2. Apple provides an easier way. Download and install Xcode, and inside the Xcode application package you will find an application called UIElementInspector. It provides a floating window that displays the complete UI element hierarchy for any UI element of any application under the mouse. The drawback is that it does not show index numbers, so for UI elements that have names you have to use the names shown in UI element inspector in your GUI Scripting scripts. For elements without names, you're stuck unless you do some more work to figure out the indexes of like elements at the same level of the hierarchy (and remember that AppleScript indexes are one-based).
As in, open the Application bundle?
The only applications I see inside the bundle are:
iPhone Simulator
Accessibility Inspector
Application Loader
FileMerge
Instruments
Printer Simulator
Hmm. It Appears that Accessibility Inspector is the new name for UIElementsInspector.
AXApplication > AXMenuBar > AXMenuBarItem > AXMenu > AXMenuItem
I guess that AXMenu is the "menu 1" and that menu doesn't have a name, it's just menu 1. It never appears in isolation with any properties.
> 3. I provide the easiest way. Download the 30-day free trial version of my UI Browser product at <http://pfiddlesoft.com/uibrowser>. Among other things, it shows the AppleScript index of all UI elements in any running target application. It also generates GUI Scripting scripts for you automatically. (To find 'menu 1' requires a few more steps even in UI Browser, but the techniques are fully explained in its Help book.)
That would be a great idea if GUI scripting was something I did more than once or twice. This was just a one-off where I was trying to make an improvement to someone else's script. Didn't know what I was getting myself into.
--
This is our music from the bachelor's den, the sound of loneliness
turned up to ten. A harsh soundtrack from a stagnant waterbed and it
sounds just like this. This is the sound of someone losing the plot
making out that they're OK when they're not. You're gonna like it, but
not a lot. And the chorus goes like this...
_______________________________________________
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