AppleScript is a language that predates the Mac as we know it today, originating in 1993. While other scripting languages have more fully featured libraries and more robust syntax, the power of AppleScript is for automating Mac applications.
Any Mac application can include a scripting dictionary, and many that ship with macOS do. A scripting dictionary lets scripts know what items the app contains, and what actions can be performed.
A script can then use that information to automate repetitive tasks, and to form a "glue" between different apps, forming fully customizable workflows.
Version | OS Release | Release Date |
---|---|---|
1.6 | 10.0 | 2001-03-24 |
1.7 | 10.1 | 2001-09-25 |
1.9 | 10.2 | 2002-08-23 |
1.9.2 | 10.3 | 2003-10-24 |
1.10 | 10.4 | 2005-04-29 |
2.0 | 10.5 | 2007-10-26 |
2.1 | 10.6 | 2009-08-28 |
2.2 | 10.7 | 2011-07-20 |
2.2.4 | 10.8 | 2012-07-25 |
2.3 | 10.9 | 2013-10-22 |
2.4 | 10.10 | 2014-10-16 |
2.5 | 10.11 | 2015-06-08 |
The power of AppleScript lies in being able to automate many Mac applications. To find out what you can automate, you need to read an app's scripting dictionary.
To do so, launch Script Editor, and select File > Open Dictionary…
Once you choose an app, its dictionary will open up in a new window. At the top of the window, you'll see a column view (like Finder's). The first column contains various "suites" of AppleScript terminology. The "Standard Suite" contains items that apply to most apps (e.g. open
, close
, save
, print
), and the other suites define custom behavior.
With Mac OS X Leopard and earlier, and OS X Yosemite and later, Script Editor is located at
/Applications/Utilities/Script Editor.app
Between Mac OS X Snow Leopard and OS X Mavericks inclusive, Script Editor is AppleScript Editor.
/Applications/Utilities/AppleScript Editor.app
Enter the following line of code:
display dialog "Hello World"
Click the run button.
Two things happen: Script Editor compiles your script (if there are any errors, it'll let you know what's wrong and where), and then runs it.
You will now be shown a dialog saying "Hello World".
You've completed your first script!
display dialog
is one command, though it uses two words. This is common in AppleScript, unlike other languages which commonly require joining words together with no spaces. The display dialog
command tells AppleScript to display a pop-up dialog.
This last part in "double quotes" tells the script what text to display.