Create an AppleScript Script without Touching a Key - dummies

Create an AppleScript Script without Touching a Key

By Mark L. Chambers

You needn’t wear a pocket protector or tape the bridge of your glasses to become proficient with AppleScript. Script Editor can get you up and running with AppleScript in no time at all. The secret weapon is the Record function of Script Editor. Just click the Record button, perform one or more actions in a recordable application, return to Script Editor, and click the Stop button.

Script Editor stores each action and compiles the whole list into an AppleScript.

In theory, this is how it should all work. In reality, though, finding recordable Macintosh applications isn’t always so easy. Finder is, perhaps, the most recordable application on the Mac. Although some other applications support recording, so few do that Finder could be the only recordable application most Mac users ever see.

To try it yourself, take the following steps to automate actions in Finder:

  1. Bring Script Editor to the foreground.

    If Script Editor isn’t running, double-click its icon in a Finder window. If it is running, click its icon (which bears a script scroll and a pen) on the Dock.

  2. Create a new script by pressing Command+N.

  3. Click the Record button.

    The Record button is the first of the four buttons positioned near the top left of a new script window.


  4. Switch to Finder, and perform the actions you want to automate.

    When Finder is active, you can select some icons on the Desktop and move them around, resize any open Finder windows, or navigate to your Home directory. Any action that you perform in Finder should be acceptable fodder for Script Editor. As you now perform tasks in Finder, Script Editor automatically generates a script that replicates your actions.

  5. Return to Script Editor, and click the Stop button.

    To reactivate Script Editor, click its icon on the Dock. Click the Stop button to cease the recording of your script.

When you’re finished, you should be looking at a complete AppleScript. To test your work, return to Finder and return any icons or windows that you might have moved or repositioned to their original locations. (You don’t want to run a script that doesn’t appear to have any effect.) Then return to Script Editor, and click the Run button to watch your automated Finder tasks being performed.