Review: AppleScript: The Missing Manual (book)
Although I’ve been writing small AppleScripts for over 10 years, I’ve never taken the time to actually pick up a book on the subject. For the longest time, the language has been lauded (and criticized) for its easy-to-read English-like syntax. The ease of reading existing scripts and adapting the principles to my own needs kept me from realizing how little I actually knew about the world of AppleScript; the shortcomings of my knowledge finally dawned on me when I figured out what that “<Inheritance>” notation in program dictionaries meant. That’s why I jumped at the chance to review AppleScript: The Missing Manual.
Adam Goldstein’s entry into the world of AppleScript tomes is remarkably complete, given its publication date (February, 2005). Before even getting into the programming aspects of AppleScript, this Missing Manual provides you with certain prerequisites for a successful scripting experience. The Script menu is examined in some depth, as are the scripts that Apple includes in this menu.
You’re also exposed to the Script Editor in some depth, which is good, since you’ll be spending a decent amount of time in it while you’re reading this book. At first glance, Script Editor seems like a fairly simple application, hardly worth a whole chapter. However, Goldstein manages to point out a few features of this application that I did not previously know about. Simply learning about the existence of Script Editor’s Navigation Bar was almost enough to make me put the book down and declare victory. Then I realized I still had nearly 300 more pages to scour for even more information.
Scripting Basics
After explaining some of the mechanics of creating and using AppleScripts, AppleScript: The Missing Manual covers the basic components of scripting. Chapters four, five, and six deal with managing text, files, and lists, respectively, providing the some of the pieces needed to understand the more complicated scripts later in the book.
The chapter on text manipulation does a good job of showing the strengths of AppleScript in general and AppleScript: The Missing Manual in particular. It begins by covering some of the text features built into AppleScript—things like creating strings in code, storing strings in variables, combining strings, and displaying strings in dialog boxes. Although there’s a fair amount you can do with this information, AppleScript allows you to use you text within other programs. As such, several pages are devoted to dealing with text in TextEdit, Apple’s word processor that is included with every copy of OS X.
Even though the price is right for TextEdit, many people prefer using a more powerful alternative, like Microsoft Word. In recognition of this fact, this chapter also adapts some scripts for use with Word and discusses some of the differences between writing scripts for Word and TextEdit.
When I finished reading these chapters, I was a little disappointed because I hadn’t read anything about records. Records are clusters of information, sort of like lists, except that the record entries are named (among other things, of course). My concerns were unfounded, as records were covered in a later chapter on databases.
Between explaining the concepts of lists and records, AppleScript: The Missing Manual discusses the scriptability of several popular applications. The applications discussed in these chapters cover a broad range of uses and prices. From free applications like iTunes and Mail to hundred dollar-plus powerhouses like Photoshop and FileMaker Pro, this book covers techniques and sample scripts for dealing with graphics, sounds, movies, and network applications.
Some of the scripts presented in these chapters simply replicate existing functionality in programs, while others expose functionality than normally would not be available in the application. For example, there is one script that simply applies a pre-existing Photoshop action to the active image and another script that lets you set a rating for the currently playing song in iTunes. Although these are simple tasks inside of their respective applications, these scripts definitely have value. The aforementioned Photoshop AppleScript is later used as a component of a more complex AppleScript that performs a series of image manipulations. The iTunes song rating script is an example of taking functionality from a program and accessing it from outside said program—using this AppleScript, you could modify your song ratings from the Script menu instead of bringing iTunes forward or activating iTunes’s Dock menu.
An example of a script that exposes functionality not usually available within the application is an iPhoto AppleScript for making an album of all pictures with given dimensions. Ironically, the book cites this script as an example of something that could easily be done in iPhoto through the use of a Smart Album and encourages you to use this script as a starting point for other scripts. As far as I can tell, though, there’s no way to create a Smart Album based on image dimensions.
This section also covers some more advanced AppleScript topics that you apply to the relevant programs. For instance, some of the Power User Clinics in these sections cover running JavaScript code in Safari via AppleScript and adding new functionality to Address Book through AppleScript plug-ins.
Advanced Topics
At the end of the chapters on basic scripting, you will be able to do many things with AppleScript. Over the years, though, the AppleScript environment has grown beyond these basics. The next section in the book covers many of the advancements
Two of the chapters deal with different ways you can use your AppleScripts. Goldstein covers folder actions from the enabling of folder monitoring through attaching your own scripts to folders. He also tackles the integration of AppleScript and Unix, both by running AppleScripts through either the command line or cron, and running Unix commands in the context of an AppleScript.
The other three chapters deal with ways to write AppleScripts. The plusses and minuses of GUI Scripting are discussed, as is the way you can control a program through its user interface elements. Debugging techniques are explained to help you figure out why your AppleScripts don’t behave like you expect. Finally, you can learn about using AppleScript Studio to create more complex AppleScript-based programs using Xcode and Interface Builder, two of Apple’s free developer tools.
Slightly Dated
The only real shortcoming I can find in AppleScript: The Missing Manual is that its information is already slightly dated. Since the book was published in February, it doesn’t contain any of the AppleScript changes introduced in Tiger. In my mind, the most noticeable difference is Script Editor’s new dictionary viewer; the new viewer offers far more options than the two-pane viewer shown in the book and used, I believe, in every previous version of AppleScript.
Had this book been published after the release of Tiger, I think that using AppleScript in conjunction with Automator actions would be a candidate for inclusion in the advanced topics section.
Even without this newer information, AppleScript: The Missing Manual does an excellent job of introducing the reader to the world of AppleScript while delving into a number of in-depth features. Whether you’ve never used AppleScript and want to start or you’ve been using AppleScript for some time and are ready to learn more, this is one Missing Manual you should add to your collection.
Also in This Series
- Review: AppleScript: The Missing Manual (book) · June 2005
- Review: AppleScript: The Definitive Guide (book) · April 2004
- Review: AppleScript in a Nutshell: A Desktop Quick Reference (book) · October 2001
Reader Comments (1)
Add A Comment