Programming AppleScript

AppleScript is a relatively simple programming language with a forté for gluing Macintosh applications together. While you can use it to a limited extent as a general programming language, its real power comes from its native ability to sling Apple Events around, letting even inexperienced programmers create interapplication scripts, as well as programs that drive a single application through a certain multistep task.

About Apple Events

An Apple Event is simply a message that one application running on a Mac OS X system sends to another (or itself), running either on the same computer or on another Macintosh via a network connection. (Technically, the recipient application can even be a program running in a non-Mac OS X environment, if it happens to answer to the Apple Events messaging protocol, but this sort of cross-platform messaging is more often handled by SOAP or XML-RPC.)

On Mac OS X, Apple Events are implemented through Mach kernel messaging, a feature of the operating system’s lowest levels. However, for maximum compatibility and maintainability, Apple recommends that developers prefer Apple Events for their software’s interapplication functionality. This isn’t something you need to think about while writing AppleScripts (which speak strictly in Apple Events), but it is something to keep in mind when writing more sophisticated applications. See Section 16.3, later in this chapter.


Apple Events do not offer a way to broadcast information to other ...

Get Mac OS X in a Nutshell now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.