Hang Ten: AppleScript And OS X - What The Present & Future Holds For Automating Activity On Your Mac

by Gene Steinberg

Sunday, August 26, 2001

AppleScript

What AppleScript Can Do

The word script connotes an arcane language that is apt to confound and befuddle all but the most experienced Mac users. Yet AppleScript, while not quite plain English, is close enough to make it possible for folks like you and me to create scripts. What's more, with the scripts already available, you might be able to get all or most of the desktop automation you want without having to make anything at all.

In effect, AppleScript lets Mac programs communicate with one another and with the operating system. The scripts you make tell these programs what to do. For example, you might want scripts to automatically copy a file from one disk to another, to batch-process a se-ries of images and apply certain Photoshop filters to them, and to save and print documents. And that's just the beginning. Many of the most popular Macintosh productivity programs depend on AppleScript to exploit some of their most useful features.

NOTE: If you want to learn what sort of support an application has for AppleScript, check the application's documentation. AppleScript's uses range from the simple to the complex, and all variations in between.

Here's a brief idea of what you can do with AppleScript:

* Automate use of the Mac OS X Finder ~ Many common Finder functions can be scripted. That means you can use complex file-management features by launching a single script.

* Automate Mac OS system functions ~ From searching the Internet, to automatically adjusting a specific set of settings, AppleScript can handle operations that require repeating steps.

* Automate workflow ~ This is where AppleScript comes into its own in a working environment. Users of the popular desktop publishing application QuarkXPress, for example, can create scripts that access specific templates for pages, flow in text, import images, and scale and crop the images. In Adobe Photoshop, a script can be used to open all the images placed in a single folder, apply a specific set of program filters to them, and then save the images in a specific file format. Imagine if you had to do all this work manually, one step at a time.

* Record your actions? You don't have to write all your scripts from scratch. Many programs (and the Mac OS X Finder) let you record a series of actions, using Apple's Script Editor application. After the steps have been recorded, you can save them as a script, and then have them run the same as any other AppleScript.

AppleScript, however, is not the only desktop automation feature. Some commercial programs, such as CE Software's QuicKeys..($87), perform similar functions, but have the added advantage of working with all Mac software, not just those that can be specifically scripted. QuicKeys for Mac OS X has been announced (see Figure 1). It might be available by the time you read this article.

Figure 1: A long time favorite, QuicKeys is making the migration to Mac OS X

What Doesn't Work in Mac OS X Some features of the Mac OS X version of AppleScript might not be completely functional. An example is the Folder Actions feature, which allows you to attach specific functions to a folder when it's opened. AppleScript features are works in progress, and more features will be added over time. Fortunately, your existing scripts ought to work pretty much the same under Mac OS X as they did under the Classic Mac OS. In addition, printing and network scripting and program link-ing were not initially supported.

Apple suggests, however, that when you create scripts you should identify the operating system version, in case problems arise when switching from one to the other. That'll make the process of testing and removing bugs from the script easier.

Mac OS X Script Features When you get started with AppleScript, you'll find that a number of Mac applications support a feature and thus will provide quite a degree of exposure to what this valuable tool can do. These include such standard applications as QuickTime Player, Sketch, and TextEdit. In addition, AppleWorks 6.1, which has been rewritten to support Mac OS X, can be scripted, as can Casady & Greene's MP3 program, SoundJam MP (now discontinued).

The Tools for Using Scripts in Mac OS X Aside from the built-in functions of some programs that use AppleScript behind the scenes, an AppleScript can come in several forms, as an applet, as a fully compiled script, or as a text file containing the script commands. Which form to use depends on the program you're running, but the most common form of script is the applet. An applet is a small application you can double-click on to start it or on which you can drag and drop an item that is subjected to the scripting action.

NOTE: In addition to double-clicking and dragging and dropping, you can place an AppleScript applet in the Dock so that it can be activated with a single click. There's even a script that can quit the Dock, in case you would rather not use it.

In Mac OS X, Apple has included a convenient way to run your scripts. It's an application called Script Runner, which allows you to execute any number of scripts from a single floating palette (see Figure 2).

Figure 2 The Script Runner in this picture has already been loaded with a number of useful scripts for Mac OS X.

AppleScript: The Future The future of AppleScript is wide and vast. Apple has made no bones about the fact that the present iteration of its system-wide scripting language works just fine with both the Carbon and Cocoa environments, so it doesn't matter whether software developers use either. In addition, AppleScript continues to function with Classic applications, so there's no fear about losing the functionality of scripts made with such programs as Adobe Photoshop and QuarkXPress.

NOTE: Both Adobe and Quark have committed to bringing their applications into the Mac OS X environment. You'll want to check with these publishers for estimated timetables. It appears that QuarkXPress will be updated later rather than earlier. They have indicated that the version they were working on when this article was formulated would first appear as a Classic application.

What's more, Apple plans to extend AppleScript support for the Unix environment as well.

To comment on this article click here ... For more information on OS X visit MacSpeedZone's X-Files


The article above is excerpted from the book "Mac OS X Little black Book" by Gene Steinberg
Copyright 2001 The Coriolis Group.All rights reserved. 
Reproduced here by permission of the publisher

________________________________________________________

For a low price on
this book click here

 

 

 

Gene Steinberg is an accomplished author with a number of Mac books to his credit. He is a contributing writer for macHOME magazine, a columnist for the Arizona Republic's Arizona Central Computing page, and a regularly featured guest on Craig Crossman's Computer American radio show. He also maintains his own Web site - The Mac Night Owl and is the Co-Author, with his son, of "Attack of the Rockoids"


Additional OS X books
 
Comparison shop for the lowest price (including tax & shipping charges) on any Macintosh product

Discussion Board

For Free Macintosh Hardware Click Here

| Top |