Chapter 7. An Introduction to AppleScript

You can think of AppleScript programs (called scripts) as software robots. A simple AppleScript might perform some simple daily task for you: backing up your Documents folder, for example.

A more complex script can be pages long. In professional printing and publishing, where AppleScript enjoys its greatest popularity, a script might connect to a photographer’s hard drive elsewhere on the Internet, download a photo from a predetermined folder, color-correct it in Photoshop, import it into a specified page-layout document, print a proof copy, and send a notification email to the editor—automatically.

Even if you’re not aware of it, you use technology that underlies AppleScript all the time. Behind the scenes, numerous components of your Mac communicate with each other by sending Apple Events, which are messages bearing instructions or data that your programs send to each other. When you use the Show Original command for an alias, or the Get Info command for a file or folder, an Apple Event tells the Finder how to respond. Many of the files in the Speakable Items folder (Section 14.4.2), furthermore, are AppleScripts that quit your programs, open AppleWorks, switch a window into list view, and so on.

Running Ready-Made AppleScripts

You don’t have to create AppleScripts to get mileage out of this technology. Mac OS X comes with several dozen prewritten scripts that are genuinely useful—and all you have to do is choose their names from a menu. “Playing ...

Get Mac OS X: The Missing Manual, Second 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.