Latest in Apple script

Image credit:

AppleScript: the Script Editor

Cory Bohon

Before you can build your first AppleScript you need to know some basics: what a script-able application is and how to use the Script Editor.

Script-able Applications
Basically, script-able applications are applications in which the developer has included a set of "instructions" that the Script Editor understands and can use. Some apps are not script-able but most Apple apps are and, of course, Mac OS X itself is script-able.

The Script Editor
The Script Editor is a very simple application, but it allows you to do some very powerful things. The Script Editor is located in your Applications folder (Applications : AppleScript : Script by default. The editor has a simple interface with a prominent text entry area. It also has 5 buttons in the toolbar; for now we will only focus on the "Run" and "Stop" buttons. The run button will run the currently typed script, and the stop button will cancel a running script.

Running a Script
Let's delve right into the Script Editor by running your first AppleScript! We will use the "tell" command. This command will allow you to tell a specific application to do something. For instance, if I wanted to open iTunes, I would type:

tell application "iTunes" to activate

You can substitute "iTunes" with any other application on your Mac, however, you must retain capitalization and spacing (if any) and include the quote marks around the application name. Now try typing the script and clicking the "Run" button at the top of the window. iTunes will open. Substitute activate with quit and run the script again. iTunes will now quit.

As you can see, AppleScript commands are very "English-like" in their structure. This is one reason that AppleScript is very easy to pick up as you go along.

Congratulations, you've just made your very first AppleScript!

From around the web

ear iconeye icontext filevr