Writing Commands by Hand

Using the “watch me” mode described earlier in this chapter, you can create only very simple scripts. If you want to create anything more elaborate—or anything at all in the Mac OS X Finder—you must type out the script steps one by one, testing your work, debugging it, reworking it, and so on.

Scriptable Programs

Most of the introductory articles you’ll read about AppleScript discuss scripts that perform useful tasks in the Finder—that is, scripts that manipulate your files, folders, disks, and so on. That’s because the Finder is an extraordinarily scriptable program; AppleScript can control almost every element of it.

But AppleScript can also control and communicate with almost every popular Mac program: FileMaker, AppleWorks, Adobe and Microsoft applications, and so on. Sherlock, iTunes, QuickTime Player, Terminal, TextEdit, Print Center, Mail, Internet Connect, and Image Capture are among the built-in Mac OS X programs that you can control with AppleScript scripts, and the list will grow with subsequent Mac OS X updates.

Almost every Mac program understands four AppleScript commands: Open, Print, Quit, and Run. These commands constitute part of what Apple has designated the Required Suite of commands. Even so, some programs don’t understand any of them, and some understand many other commands.

But before you can write a script that manipulates, say, Eudora, you need to learn which commands Eudora can understand. To do that, you need to look at the application’s ...

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.