How Does AppleScript Work?AppleScript works by sending messages, called Apple events, to applications. When you write a script, you write one or more groups of instructions called statements. When you run the script, the Script Editor sends these statements to the AppleScript extension, which interprets the statements and sends Apple events to the appropriate applications. Figure 2-1 shows the relationship between the Script Editor, the AppleScript extension, and the application.
The parts that you use--the Script Editor and the application--are shown to the left of the dotted line in Figure 2-1. The parts that work behind the scenes--the AppleScript extension and Apple events--are shown to the right of the dotted line.
Applications respond to Apple events by performing actions, such as changing a text style, getting a value, or opening a document. Applications can also
send Apple events back to the AppleScript extension to report results. The AppleScript extension sends the final results to the Script Editor, where they are displayed in the result window.
When you write scripts, you needn't be concerned about Apple events or the AppleScript extension. All you need to know is how to use the AppleScript language to request the actions or results that you want.