Chapter 12. Scripting Programs That Don’t Have Dictionaries

In every script since Chapter 1, you’ve used AppleScript commands that come from programs’ dictionaries. Dictionaries are the cornerstone of application control (Section 3.2.2), and they’re great for discovering new commands. The only problem is, not every program has as a dictionary.

Some programs, like Chess, are too unimportant for Apple to create a dictionary. Others, like System Preferences, have such limited dictionaries that they’re almost not worth mentioning. Still other programs are written by overworked third-party programmers, who might not fully comprehend the benefits of making their application AppleScriptable. And programs like Final Cut Pro and GarageBand really ought to have AppleScript dictionaries, but Apple hasn’t gotten around to writing them. If you want to script such programs, you’re left out in the cold—or so you might think.

The fact is, every program—even one without dictionaries—supports three universal commands. They’re not particularly powerful, but they form the backbone of most scripts.

Table 12-1. Commands you can send to any program

Command

What it does

activate

Brings the target program forward, launching it if necessary.

launch

Opens the target program but doesn’t bring it forward.

quit

Closes the target program, asking you to save any unsaved documents in the process.

If you only used those three commands, however, you’d be left with some pretty dinky scripts. Of course, if the program you’re ...

Get AppleScript: The Missing Manual 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.