Language Guide
CHAPTER 8
Handlers
Command Handlers for Script Applications 243
Command Handlers for Script Applications 8
Getting Started With AppleScript describes how you can use the Script Editor to
save a script as a script application. A script application is a script that you can
run from the Finder much like any other application. If you save a script as a
stay-open application, it stays open after it runs; if you don’t, it quits right after
it runs.
Every script application can respond to at least two commands: the Run
command and the Open command. Like any other application, a script
application receives a Run command whenever it is launched, and an Open
command whenever another icon is dragged and dropped over its icon.
Stay-open script applications can also receive and handle any other commands.
All stay-open applications receive periodic Idle commands whenever they’re
not responding to other events and Quit commands whenever the user quits
the application.
This section describes handlers for the Run, Open, Idle, and Quit commands. It
also describes how you can call a script application from another script.
Run Handlers 8
All applications that are compatible with System 7 can respond to the Run
command, even if they aren’t scriptable. The Finder sends a Run command to
an application whenever that application is not already running and one of the
following actions occurs:
■ The user double-clicks the application’s icon.
■ The user selects the application’s icon and chooses Open from the File menu.
■ The application’s icon is in the Apple Menu Items folder and the user
chooses it from the Apple menu.
■ The application’s icon is in the Startup Items folder and the user restarts
the computer.
If the application is already running when one of these actions occurs, the
application is activated but no commands are sent to it. If the application isn’t