The joy of Applescripting

One of the selling points for spending money on information technology in any company is that it will allow people to be more productive by removing the need to do repetitive tasks.

One of the selling points for spending money on information technology in any company is that it will allow people to be more productive by removing the need to do repetitive tasks. However, the traditional problem with implementing solutions that do this for complex tasks (ones that involve the use of several specialist applications), is that the applications themselves tend to operate in closed worlds that force the user to manually link everything together.

Apple's solution to this problem was introduced over a decade ago and has become the secret weapon of professional Mac OS users looking for workflow automation. The API that implements this solution is called the Open Scripting Architecture (OSA) and it provides a standard way for developers to create applications that can communicate with one another on behalf of the user. These interapplication communications are done using what are known as Apple Events, and their power can be accessed with the English-like object orientated scripting language, AppleScript.

The AppleScript language itself includes all of the basic constructs you need for scripting, but the real power comes from extending it using the scripting dictionary's collection of applications and Scripting Additions. Basically, the dictionary is an application's way of translating the Apple Events it can deal with into something resembling English and Scripting Additions are extensions to the language itself. Scripting Additions are readily available on the web and provide functionality ranging from advanced text handling to managing X10 devices.

To create a script, though, you need an editor that can compile and create script applications. The aptly named Script Editor application that is bundled with the OS definitely does the job. Script Editor is a bit on the basic side, but it has the ability to record your actions in an application that supports recording and turn the results into a script. For more professional users, though, applications such as Scripter 2.5 by Main Event Software and Script Debugger 3.0 by Late Night Software are essential tools.

Once you have the tools, the sky's the limit. Scripts that aide your workflow can be as simple as ones that take a folder of files and rename them, to ones that take a folder of graphic files, associated text files and a template, and automatically make a catalogue in QuarkXPress using programs like Graphic Converter and Adobe Photoshop to tidy up the graphic files where necessary. With the X10 extensions it is even possible to use AppleScript to control your coffee maker--now that's workflow automation.

Mac OS X has really given AppleScript a new lease of life in three major ways. Firstly, you can now control standard command line programs from your scripts. Secondly, XML-RPC and SOAP support is built in allowing your scripts to gather information from the internet. And thirdly, Apple has released AppleScript Studio which allows developers to make their AppleScripts first class Mac OS X applications with a full graphical user interface. Putting it all together, you can now use AppleScript to create a fully fledged application that can request information from the internet and process it using standard command line tools.

AppleScript has always been undersold by Apple, but with these improvements it looks as if it is finally starting to get the respect it deserves as a professional workflow automation tool.

Chris White is MIS manager at Cookie Time in Christchurch. Send letters for publication in Computerworld to Computerworld Letters.

Join the newsletter!

Error: Please check your email address.

Tags Mac Manager

More about Adobe SystemsAppleLate Night SoftwareMISOSAX10

Show Comments
[]