![]() |
|
|
|
|
|
|
|
|
DISCOVERING AN OBJECT'S HIERARCHY UI elements are positioned in a hierarchy of other elements that make up the visual interface of an application. As with objects in scriptable applications, UI elements are referenced by their position in their object hierarchy. For example, a button could be in a scroll list in a view group in a sheet attached to a window. In order to script a UI element, it is essential to know the exact series of objects that contain it. The discovery of an object's hierarchy can be done with a free utility called the UI Element Inspector, which can be downloaded here. When launched, the UI Element Inspector presents a small floating palette that displays information about any object that the cursor is over. The target object's containment hierarchy is displayed at the top of the palette window. To script the target object, translate the hierarchy into AppleScript terms using the Processes Suite from the System Events dictionary, as shown in the following example. The following example demonstrates how to translate an object's hierarchy into a script by scripting the Arrange menu item of the Finder's View menu.
![]()
tell application "Finder" end tell tell application "System Events" end tell Extras Those wishing to explore the more advanced features of the UI Element Inspector should try putting the cursor over a target object, such as a Finder window, and type the keys Command-F10 to put the UI Element Inspector in a UI lock mode. In the forthcoming Locked on... palette, select the Highlight checkbox to place a pink highlight over the target object. Use the goto popup menu to discover and highlight the children or objects belonging to the target object. Their information will display in both palettes. To exit UI lock-mode, type Command-F10 again. ![]() And for those desiring an easier, less technical means of generating script statements for UI elements, visit Prefab Software's website for the Prefab UI Browser, an easy-to-use UI scripting utility. |
TABLE OF CONTENTS Introduction Activating UI Scripting - Enabling the GUI Scripting architecture UI Element Inspector - Discovering an object's heirarchy Example Scripts - Example scripts and routines |