Chapter 14. AppleScript

By scripting, we mean writing programs that act as “glue”; they pass information between other existing applications to suit some purpose or act as macros, letting a user execute several commands in some program (or across several programs) with a single gesture. In this terminology, scripts are different from full-on applications because they lack a user interface; they just do their job and exit.

The highest-level scripting language on Mac OS X is AppleScript, initially developed by Apple in the early 1990s. AppleScripts enjoy a special dispensation on the Mac because of their native handling of Apple Events, which are simply messages Mac applications pass to one another. The majority of this chapter covers AppleScript, as well as AppleScript Studio, which allows you to use Xcode and Interface Builder to build AppleScript-based GUI applications for Mac OS X.

The Script Menu Extra

Apple’s Script menu extra (see Figure 14-1) offers perhaps the most convenient way to run scripts, both of the AppleScript and shell script variety. It doesn’t appear in your menu bar by default, but installing it is very easy: just double-click on the Install Script Menu program, found in /Applications/AppleScript. The Script menu extra pops into your menu bar and remains there until you either manually remove it (by command-dragging it off of the menu bar) or run the Remove Script Menu program.

Figure 14-1. The Script menu extra

This menu extra gets its contents from the /Library/Scripts ...

Get Mac OS X Panther in a Nutshell, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.