Section 12.2. GUI Scripting Basics


12.2. GUI Scripting Basics

The cornerstone of GUI Scripting is the invisible program named System Events. Earlier, you used System Events to get a list of all the processes (or running programs) on your Mac. But even more powerfully, you can use System Events to control these processes, clicking buttons and typing keystrokes from AppleScript.

The first step, then, is to open System Events's AppleScript dictionary in Script Editor (File Open Dictionary System Events). Since you want to learn how you can control processes, take a look specifically at the Processes Suite (Figure 12-2). Inside, you'll find:

  • Classes. Here, you can discover all the different kinds of interface elements you can control with your scripts: windows, menu items, buttons, text fields, and more. Later, when you write a script, you'll specify individual interface elements (like window "Universal Access") to direct your script to click or type in a certain part of the screen.

  • Commands. These are what do the real work of GUI Scripting: clicking and typing. You send commands like click (see the next page) and keystroke to particular processes, and Mac OS X pretends that you yourself clicked or typed into those programs.

Figure 12-2. Although System Events has a number of different suites (like the Text Suite [Section 4.6.1] for manipulating words and sentences) the most useful suite is the Processes Suite. There, you can find out how to control programs through their interfaceseven for programs that don't have AppleScript dictionaries of their own!


Keep this dictionary open as you proceed through this chapter. That way, if there's a command you're not familiar with, you can look it up in the Processes Suite.



AppleScript. The Missing Manual
AppleScript: The Missing Manual
ISBN: 0596008503
EAN: 2147483647
Year: 2003
Pages: 150

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net