Language Guide
CHAPTER 4
Commands
74 Types of Commands
For more examples of how to use Copy, Count, Get, Run, and Set, see the
command definitions later in this chapter.
Scripting Addition Commands 4
Scripting additions are files that provide additional commands or coercions
you can use in scripts. Each scripting addition can contain one or more
command handlers. If a scripting addition is located in the Scripting Additions
folder (in the Extensions folder of the System Folder), the command handlers it
provides are available for use by any script whose target is an application on
that computer.
Like the target of an application command, the target of a scripting addition
command is always an application object or a script object. If the script doesn’t
explicitly specify the target with a Tell statement, AppleScript sends the
command to the default target application, which is usually the application
running the script (for example, the Script Editor).
A scripting addition command performs its action only after the command has
been received by a target application. Unlike application commands, scripting
addition commands always work the same way regardless of the application to
which they are sent.
For example, the scripting addition command Display Dialog displays a dialog
box that can include text, one or more buttons, an icon, and a field in which the
user can type text. In the script that follows, the target of the Display Dialog
command is the Scriptable Text Editor application. When the script runs, the
Scriptable Text Editor becomes the frontmost application (that is, its menus
become visible and its windows become the frontmost windows on the screen)
and passes the command to the scripting addition’s handler for the Display
Dialog command, which displays the dialog box.
tell application "Scriptable Text Editor"
display dialog "What’s your name?" default answer ""
end tell
In the next example, the Display Dialog command is not enclosed in a Tell
statement, nor does it have a direct parameter, so its target is the Script Editor
(or whatever application runs the script). When you run the script, the Script
Editor passes the command to the scripting addition’s handler for the Display