How AppleScript works

    When you double-click the icon of an application, the Finder sends a message to the system that this event has occurred. The system then sends a message to the application to open. Most of the tasks you do on your computer happen through a series of "events" like these.

    Events are usually caused by users, but other programs, such as AppleScript, can send events to programs to tell them what to do. When you run a script, each statement sends a message to AppleScript. AppleScript uses some of these messages to control the action of the script. It sends other messages as commands to programs, which then carry out the command.

    In some cases, applications send back a result. For example, if a script asks for the setting of an option, the program returns information that indicates the setting. If the program cannot respond to the command, then the program or AppleScript may return an error message.

    You can see these results in the Script Editor. You can also have a script check the result of a command to decide what action to take next.

 


Table of contents