O'Reilly logo

AppleScript: The Missing Manual by Adam Goldstein

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Deciphering Interface Hierarchies

Whenever there's an interface element (like the Sticky Keys radio button) that's deep inside a window, your best bet is to use Apple's UIElementInspector tool. This powerful program, available from http://www.apple.com/applescript/uiscripting/downloads/uiinspector.dmg, gladly reveals the hierarchy of your windows, so you can figure out precisely how to script an interface element.

Once you've downloaded the program, copy it into your Applications folder. From there, follow these simple steps to script the Sticky Keys radio button:

  1. Double-click UIElementInspector in the Finder.

    The program opens but without a menu bar or Dock icon. You deal with UIElementInspector entirely through its mini-title-barred windows.

  2. Hover your mouse over the Sticky Keys "On" radio button in System Preferences.

    UIElementInspector displays bits of geeky information, telling you the radio button's name, size, position, and so on.

    Note

    If you want to inspect a different interface element—say, a text field or a checkbox—simply hover your cursor over that element instead.

  3. Press -F10 to lock UIElementInspector's current display (Figure 12-6).

    That'll allow you to move the mouse around without worrying about changing what's in the Inspector window.

    For a more thorough explanation of UIElementInspector's features, check out http://www.apple.com/applescript/uiscripting/02.html.

  4. Examine the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required