written by: Finn Orfano•edited by: Michael Dougherty•updated: 12/7/2009
AppleScript is built into Mac OS, you can use it to automate a large number of jobs. Unlike VBA, which is limited to Word, Excel and PowerPoint, AppleScript works across the Mac
slide 1 of 1
What is AppleScript?
AppleScript is a scripting language shipped with Mac operating systems. It lets you automate tasks and widen the functionality of the operating system. You can use AppleScript to mount network drive, print a document, download a file, shut down your computer, back up a folder and more. AppleScript brings ease to your life by enabling you do many tasks easily and quickly, for example everyday you back up the contents of your folder to a disk before turning the computer off. The folder is large so it takes lot of time for back up to complete so you have to wait 15-20 minutes before you can shut down the system. So you use AppleScript that automates the tasks, you just run the script and forget everything. The AppleScript will take the backup of your folder and then shutdown the computer automatically. Similarly, you can automate many other tasks like this. One of the most powerful things about AppleScript is its ability to communicate between applications. It helps in automating multiple operations by running only one script.
AppleScript has a number of components; let us see what they are and what these are used for.
1. AppleScript Files
There are three types of AppleScript files:
Text Files These files contain AppleScript statements. You can only open them with any text editor or a Script Editor and can be run from within the Script Editor.
Scripts These are complete scripts, which can be run from an application’s script menu.
Applications These are full-fledged scripts that perform complete operations, these can be run by double-clicking their icons.
2. Script Editor
Script Editor is an application included in Mac operating system; you can use it to write AppleScript scripts. The Script Editor comes with a number of very useful features that let you very easily write scripts. Some of its good features include sytax checker to examine script statements, auto formatting of script statements, the record script feature and more.
People who do not like the AppleScript Script Editor can use Smile, it is a third-party IDE for writing AppleScripts and is more advanced than Apple’s Script Editor for creating scripts.
3. AppleScript Dictionaries
Dictionaries provide syntax information for correct AppleScript classes and commands. Classes are like objects, which a command is performed on. For example in TextEdit, ‘close’ is a command, which can be performed on a related object such as ‘window’. Commands can be referred to as verbs that say to an application to do something. Anyone who wants to write scripts will find dictionaries very valuable.
4. Script Menu
Script menu is a small tool that lets you access your AppleScripts from the Finder’s menu bar. It adds a menu containing many example scripts to the Apple menu bar.
say "Hello World!"
This short piece of AppleScript will say Hello in a default person's voice.
Many Mac OS X applications support AppleScript. Some of the applications that support AppleScript include iPhoto, Microsoft Word, Excel, Adobe illustrator, Photoshop and many more. You can find more information about AppleScript, sample scripts and tutorials on Apple’s website and on www.MacScripter.net