Chapter 21. Scripting Additions
A scripting addition (or osax) is a compiled code fragment, typically written in a language such as C, that extends the AppleScript language (see "Scripting Addition" in Chapter 3). A scripting addition has a dictionary, but it can't be targeted, and doesn't need to be; the commands that it implements are present as if built into AppleScript itself (see Chapter 20).
A scripting addition can define events (commands), records (pseudo-classes), and coercions. Generally speaking, a scripting addition can fulfill two purposes:
- Add to AppleScript's powers
AppleScript is a "little language" (see Chapter 4), and in some ways it's just too little. A scripting addition can supplement AppleScript's powers by implementing additional commands.
- Define events
A scripting addition's dictionary can provide terminology for an event that some application might send to your script. Using this terminology, you can write an event handler to respond to the event. (See "Event Handlers" in Chapter 9.)
The default Tiger installation includes one scripting addition that adds to AppleScript's powers—the StandardAdditions osax. Many of the commands that it implements are so fundamental that this book treats them as part of the core language—for example, display dialog
, which is used in examples throughout the book, and the very important load script
and store script
commands (see Chapter 8). (The other installed scripting addition, Digital Hub Scripting, implements no functionality; ...
Get AppleScript: The Definitive Guide, 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.