Re: menu bar 1 in 10.8?
Re: menu bar 1 in 10.8?
- Subject: Re: menu bar 1 in 10.8?
- From: Bill Cheeseman <email@hidden>
- Date: Thu, 27 Jun 2013 09:54:00 -0400
The issue was the lack of menu 1. I tried many different variations and ended up posting one without "process", but mostly what I was trying was along the lines of
tell application "System Events" to tell process "Mail"…
But I kept changing things as I could never get it to work, not knowing about menu 1.
Here are three ways to get what is called the UI element hierarchy of an application:
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:
tell application "System Events" tell process "Finder" get value of attribute "AXChildren" end tell end tell
In AppleScript Editor, this returns this array:
{window "cheeseb" of application process "Finder" of application "System Events", scroll area 1 of application process "Finder" of application "System Events", menu bar 1 of application process "Finder" of application "System Events"}
To move down a level and get the hierarchy of window "cheeseb", use this script:
tell application "System Events" tell process "Finder" get value of attribute "AXChildren" of window "cheeseb" end tell end tell {button 1 of window "cheeseb" of application process "Finder" of application "System Events", button 2 of window "cheeseb" of application process "Finder" of application "System Events", button 3 of window "cheeseb" of application process "Finder" of application "System Events", static text "12 items, 217.32 GB available" of window "cheeseb" of application process "Finder" of application "System Events", splitter group 1 of window "cheeseb" of application process "Finder" of application "System Events", tool bar 1 of window "cheeseb" of application process "Finder" of application "System Events", image 1 of window "cheeseb" of application process "Finder" of application "System Events", static text "cheeseb" of window "cheeseb" of application process "Finder" of application "System Events"}
And so on until you have the entire hierarchy.
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).
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.)
Bill Cheeseman
--
|
_______________________________________________
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