Summary

AppleScript makes applications perform tasks by sending Apple event messages to the applications. AppleScript is a programming language designed with everyday users in mind, but it has enough power for advanced users and programmers.

Use the AppleScript Editor application to create, edit, and run AppleScript scripts. AppleScript Editor also can make scripts into applications. You can save a script in any of three formats: text, compiled script, or application.

You type AppleScript statements into a new AppleScript Editor window, check the syntax for errors using the Compile button, and run the script to test it. Your script can use a copy statement to set the value of a variable. To start controlling an application, you use a tell application statement. A matching end tell statement stops controlling the application. With if statements, you can have AppleScript perform some operations only when specified conditions are met. Repeat loops execute a group of statements over and over. To make a drag-and-drop script application, you include an on open statement and a matching end open statement.

You can use the Script menu to run compiled scripts, no matter which application is currently active. AppleScript can control applications over a network or the Internet on computers that are set to allow remote Apple events.

Automator is a graphical interface to AppleScript that doesn't give you the same fine control as AppleScript does, but it's much easier for the average person to ...

Get OS X Mountain Lion Bible 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.