AppleScript 1.9 (Mac OS X Jaguar)

Mac OS code names are usually meant for internal use within Apple, although they inevitably leak into public usage through rumor and news sites on the Web (and even once led to a famous lawsuit by a certain well-known astronomer). Mac OS X 10.2 is different. It was officially announced by Steve Jobs at the Macworld Expo in New York on July 17, 2002 as Jaguar. When it was released on August 24, 2002 (or the evening before at Apple retail stores), the CD came with a magnificently detailed Jaguar skin motif reportedly generated by Pixar, and it is all over the Apple Web site and advertisements.

Version 10.2 brings Mac OS X to full maturity. Mac OS X has been shipping as the default boot OS on all new Mac hardware since early in the year, and Steve Jobs announced at the Paris Expo in September that in 2003 new Mac hardware will not even be able to boot into Mac OS 9 (although Mac OS 9 will still run in the Classic environment of Mac OS X).

Given this evolution, it hardly comes as a surprise that Mac OS X 10.2 includes a new version of AppleScript, version 1.9, for the native Mac OS X environment but no equivalent upgrade for Mac OS 9. All that Mac OS 9 users get out of upgrading to Mac OS X 10.2 is a handful of system components in the Classic environment that are newer than those in Mac OS 9.2.2, including the 1.8.3 versions of the AppleScript component, Standard Additions, and Script Editor, as detailed in AppleCare KnowledgeBase Document 106963. It looks like AppleScript 1.8.3 is the end of the road for AppleScript in the classic Mac OS, although it wouldn’t be astonishing to see another dot release to deal with a few remaining issues. From now on, it appears likely that these AppleScript Sourcebook reports on new versions of AppleScript will be exclusively about AppleScript on Mac OS X.

AppleScript usage in Mac OS X is very similar to its usage in the classic Mac OS, but there are also significant differences. If you’re coming to AppleScript for the first time in Mac OS X 10.2 after some previous experience of it in the classic Mac OS, we recommend that you read The AppleScript Sourcebook’s report on AppleScript 1.6 in Mac OS X 10.0 for essential background.

This report, like all previous reports, is based on information obtained from various sources, including official Apple publications and several AppleScript and Mac OS X mailing lists and news groups, as well as my own investigations on my own computers.

PRODUCT UPGRADES FOR MAC OS X 10.2 COMPATIBILITY

There has been a steady stream of new and updated applications for Mac OS X 10.2 to deal with the reported 150 new features in Jaguar. An increasing number of these applications include robust AppleScript support. Those listed here are the tools we consider most important to scripters because of their focus on providing an authoring and execution environment for AppleScript.

Script Editors and Environments
Apple’s Script Editor 1.9, new in Jaguar, is still the simple but useful script editor it has been since 1993. It remains a suitable utility for writing simple AppleScripts, and it provides a very easy pathway for newcomers to learn AppleScript. Many expert and professional scripters still use it as their primary editor, although it falls short when it comes to modern debugging aids.
Late Night Software’s Script Debugger 3.0, at version 3.0.5 at this writing, became available for Mac OS X on the day that Mac OS X 10.1 was announced, September 25, 2001. Despite a few initial collisions with the new and changed underpinnings of Jaguar, it is now a full citizen on Mac OS X 10.2. It is a capable script editor and debugger having many powerful features.
Smile 2.4.6 from Satimage is a free alternative script editor and development environment for Mac OS X 10.2 with many interesting and powerful features.
FaceSpan 4.0 is a graphical user interface builder for AppleScript applications, originally from Digital Technology International (DTI) is now owned by Late Night Software.
AppleScript Studio 1.2, a new version included with Jaguar and AppleScript 1.9, is Apple’s own offering in the graphical user interface AppleScript field. Apple has continued to make much of AppleScript Studio since its introduction in Mac OS X 10.1.2 with AppleScript 1.8.1. Most recently, shortly after the release of Jaguar, Apple’s Hot News section has launched a series of stories about real-life users of AppleScript Studio. Yours truly was featured in the first article, in August, 2002, AppleScript Studio: a marvelously easy environment. Subsequent articles include AppleScript Studio makes live easier and AppleScript Studio at NASA Langley. Developer documentation is also available. For more details, consult the following articles I wrote about AppleScript Studio: AppleScript Studio: An Introduction, MacTech Magazine, Vol. 18, No. 1 (January 2002); AppleScript Studio: Implementing an Application Preferences System, MacTech Magazine, Vol. 18, No. 5 (May 2002) ; and AppleScript Studio: Implementing a Document-Based Application,MacTech Magazine, Vol. 18, No. 7 (July 2002). The project source files for the Doyle application described in the last two articles can be downloaded here.

Scripting Additions
New Mac OS X scripting additions continue to appear. Look in the Scripting Additions section of The AppleScript Sourcebook’s Links chapter for some of them. A more complete list is available at osaxen.com hosted at MacScripter.net.
One important set of Mac OS X scripting additions, especially since the XML-RPC and SOAP protocols gained support in Mac OS X 10.1, are Late Night Software’s XML Tools 2.5 scripting addition and its brand new XSLT Tools 1.0 scripting addition, the latter currently available in beta form.
Satimage has also released its Satimage scripting addition in Mac OS X native form, as part of the Smile 2.4.6 package. It implements a number of string, math and other commands.
An essential old favorite from the classic Mac OS, Jon’s Commands, has very recently made its appearance on Mac OS X in a very early development release as Jon’s Commands X 3.0.

Scriptable Applications
Additional and revised Mac OS X applications with AppleScript support are appearing at a rapid pace. See the Scriptable Applications section of The AppleScript Sourcebook’s Links chapter for details about some of them.

NEW FEATURES, CHANGES, AND LIMITATIONS IN APPLESCRIPT 1.9

AppleScript 1.9 requires Mac OS X 10.2 or newer. It can run scripts from, and write scripts for, AppleScript versions from 1.1 through 1.9, subject to a variety of compatibility issues relating to features available in older operating systems.

New Features
Notable newcomers in Mac OS X 10.2 and AppleScript 1.9 are the Script Menu, Folder Actions, and a few new features of the Standard Additions scripting addition.

Script Menu
The Script Menu is not exactly new. An older version of it was available from Apple as a separate download for earlier versions of Mac OS X, but it is now included in the Jaguar release as an optional install. It replaces the Script Runner floating button from earlier versions of Mac OS X. (If the old Script Runner is not deleted when you upgrade to Mac OS X 10.2, delete it; it might not work correctly.)

ScriptMenu.menu is a MenuExtra plugin in the /Applications/AppleScript folder. Just double-click it to install a Script Menu at the right end of your menu bar. To remove it, Option-drag it to the desktop.

When installed, the Script Menu is populated with a large number of useful scripts from Apple, conveniently arranged into subfolders to form separate hierarchical submenus. We urge you to check them out. Apple’s scripts are located in /Library/Scripts, but you can put your own scripts there, as well, or in ~/Library/Scripts where they will appear in a separate section at the bottom of the Script Menu (create the user Scripts folder yourself if it doesn’t already exist). Not only AppleScript scripts but also Unix scripts such as shell scripts and PERL scripts can be executed from the Script Menu.

Folder Actions
Folder Actions have finally returned in Mac OS X 10.2. One of the star attractions of the last several versions of the classic Mac OS, Folder Actions are scripts that can be attached to any folder. When certain defined user actions occur, such as dropping items into a folder or opening a folder, an attached script containing a matching handler is automatically executed. This is very useful for automating any number of activities, such as processing photographs dropped into a folder.

For Folder Actions to work in Mac OS X, you have to turn this feature on. There are commands (scripts) in the Script Menu to turn it on or off. What turning it on actually does is to launch the System Events application and place it in your Login Items list so that it will be automatically launched every time you log in. You could accomplish the same thing by adding System Events to your Login Items list manually. This procedure is analogous to a similar capability that existed in the classic Mac OS, where you could tell the Folder Actions system extension (an application) to run or quit.

In Mac OS X, the AppleScript commands that can be used to attach and detach Folder Actions under script control reside in the System Events application. Open its dictionary to see what you can do with them. Some of the Folder Actions commands implemented in the System Events application are identical to those that appeared in the classic Mac OS Folder Actions system extension, but others are new and more powerful. They now include object-model capabilities, such as listing the folder actions attached to a folder, executing them directly, and determining whether the Folder Actions feature is currently turned on or off.

Example scripts to use some of these commands reside in the Folder Actions subfolder of the /Library/Scripts folder. They appear in the Folder Actions submenu of the Script Menu, where you access them to attach Folder Actions to folders and detach Folder Actions from folders. This is different from Mac OS 9, where the attach and detach commands were in a Finder contextual menu.

One welcome improvement in Folder Actions in Mac OS X is that they now work even if the folder to which they are attached is closed. In the classic Mac, you had to leave a folder’s window open if you wanted some user actions to trigger attached scripts. leading to a user interface nightmare. Another former classic Mac OS feature is currently missing in Mac OS X: the tiny badge that marked a folder as having an attached Folder Action.

An interesting feature of Folder Actions and the Scripts folder, easily overlooked, is that the /Library/Scripts folder contains a special subfolder, Folder Action Scripts (not to be confused with the Folder Actions subfolder). This special Folder Action Scripts subfolder does not appear as a submenu in the Script Menu. Instead of holding commands for the Script Menu, it is the place where you should normally store Folder Action scripts that are ready to be attached to folders. You can also create your own Folder Action Scripts subfolder in ~/Library/Scripts, and it won’t appear in the Script Menu, either.

Folder Actions are user-specific. That is, Folder Actions that one user attaches to folders will not be attached when another user logs onto the computer.

The commands, or Apple events, that you can write into your Folder Action scripts are listed in the Standard Additions scripting addition’s dictionary, just as they were in the classic Mac OS.

Standard Additions
The Standard Additions scripting addition has new capabilities to help Macs fit into Windows networks. The Mount Volume command can mount Windows (SMB), Samba and FTP servers, using a parameter like this: ‘smb://name:password@server.domain.com/sharename’. The Choose URL command will display SMB and Samba volumes.

The Say command now takes an optional Saving To parameter. Instead of speaking the text aloud, it will save it to an AIFF file. Give the file an .aiff name extension to ensure it can be used in iTunes and other Mac OS X contexts.

Changes

System Events
As you see from the discussion of Folder Actions, above, the System Events application has taken on a new, expanded role in Mac OS X 10.2. In earlier versions of Mac OS X, its role as far as AppleScript is concerned seemed to be limited to implementing certain scripting commands that used to belong to the Finder, such as listing running processes. These same scripting commands could still be executed in ‘tell application Finder’ blocks, where they would be passed off to System Events behind the scenes. Apple wasn’t sure it would retain this arrangement in the future, and scripters were warned against using ‘tell application System Events’ blocks in their scripts.

This situation is reversed in Mac OS X 10.2. Apple’s position is that ‘tell application System Events’ is a proper way to execute these former Finder commands, and of course you must use System Events for the new Folder Action commands and other new commands implemented in System Events, now and in the future. It appears that the System Events application is assuming a role as a Finderless command center for access to file system objects and processes, perhaps leading the way toward a regime where the Finder is only one of many possible user interfaces for these system features.

Among other uses for System Events are sending Shut Down, Restart, and Sleep commands, either to your machine or to remote computers. These three commands remain in the Finder’s Legacy suite and can still, for the time being, be executed in a ‘tell application Finder’ block. Now you can, and should, send them directly to the System Events application, instead, either on the local or a remote machine. (The AppleScript 1.9.0 for Mac OS X Release Notes state that AppleScript 1.9 supports a Log Out command, as well as Restart, Shut Down, and Sleep commands, but this is an error. There is a way to use AppleScript to log out, but not using System Events at this time; see the further discussion of the System Events and loginwindow applications below for details.)

In addition, System Events is beginning to acquire the ability to script individual System Preferences panes without launching the System Preferences application. In Mac OS X 10.2, System Events has commands letting you add and remove items in your Login Items list. You can also script the System Preferences application itself to a limisted extent, to count them and list them, for example, via AppleScript.

AppleScript Studio
AppleScript Studio 1.2 contains changes which won’t be covered extensively in this report. It comes with many new example projects. The documentation for AppleScript Studio 1.2 is being extensively revised and expanded, but it isn’t yet ready in final form at this writing.

AppleScript Dictionaries
A changeover from ‘aete’ resource-based scripting dictionaries to XML-based dictionaries is beginning. See the AppleScript 1.9.0 for Mac OS X Release Notes for preliminary information about the new .sdef file.

Limitations

New scripts written in Script Editor 1.9 will be saved by default as data-fork scripts, although old resource-fork scripts will retain their form if edited and resaved in Script Editor 1.9. After the release of Mac OS X 10.2, it is becoming apparent that some older applications and system facilities that work with resource-fork scripts do not work with data-fork scripts.

DOCUMENTATION FOR NEW APPLESCRIPT FEATURES

The AppleScript 1.9.0 for Mac OS X Release Notes are available on the AppleScript Release Notes page. They include additional information not reproduced here. In addition, the Mac OS X 10.2 Technical Note 2053 contains very detailed developer-oriented information about AppleScript and Apple event-related features in Mac OS X 10.2.

The Mac OS X 10.2.1 Update Release Notes mention no changes relating to AppleScript.

TESTING WHETHER APPLESCRIPT 1.9 IS INSTALLED

Before using new features of AppleScript, careful writers of scripts intended for public distribution will want to determine which version of AppleScript is present on the user’s machine.

A good, universal way to determine whether AppleScript 1.9 is available is to use a much simplified version of the script that was developed for AppleScript 1.6:


on AppleScript19orNewer()   
	tell application "Finder" to get system attribute "ascv"
   return (result is greater than or equal to 17826192)
end AppleScript19orNewer

Under AppleScript 1.9, ‘system attribute ascv’ returns 17826192, which is the integer equivalent of the binary-coded decimal version number 01100190.

APPLESCRIPT TOOLS, SCRIPTING ADDITIONS, AND SCRIPTABLE APPLICATIONS

Mac OS X 10.2 includes a few system components that have new AppleScript commands and other items in their AppleScript dictionaries, as well as a few altogether new items that are scriptable, such as the Digital Hub Scripting and Keychain Scripting scripting additions. This is, as always, good news for AppleScripters.

If there is a theme to the AppleScript changes in Mac OS X 10.2, it is that a number of scriptable system components have been created as Cocoa applications or turned into Cocoa applications. In the process, all of their dictionaries have gained the usual Cocoa Standard Suite and Text Suite of AppleScript commands. Some existing components have lost part of their former AppleScriptability, but this is probably due to time constraints and therefore temporary. Examples are Apple System Profiler and Print Center, discussed below. A counterexample is Help Viewer, also discussed below, whose scriptability has been enhanced.

I am a champion of Cocoa, and I am happy to see more of the system tools becoming Cocoa applications. Among other things, this means that as Cocoa’s built-in scripting dictionary improves in the future, these applications like all scriptable Cocoa applications will automatically gain the benefit of many of the changes. Apple continues to improve the Cocoa AppleScript dictionary, although some improvements (including improvements made in Jaguar) require incorporation of new features by developers and therefore won’t show up immediately in applications.

Installed Software and Dictionary Changes

Address Book 3.0.1 (v211)
Address Book, new in the /Applications folder in Mac OS X 10.2, is a Cocoa application. Its dictionary includes not only the usual Cocoa Standard Suite and Text Suite, but also an Address Book Script Suite containing many classes and three commands: Add, Remove, and Save Addressbook. Look under the Mail application, below, for information about scripts that come with Mac OS X for importing addresses from other popular Personal Information Managers.

I have done only limited experimentation with scripting Address Book. The promise is high, but preliminary reports from the field indicate that there may be some potentially serious problems with Address Book scriptability at this time. For example, indications are that adding persons via AppleScript can render the database unusable by other applications that come with Mac OS X 10.2, and the publisher of FAXstf reports that fax numbers saved using AppleScript are not recognized as fax numbers due to an issue in Address Book.

Apple’s AppleScript Web site indicates that an article is forthcoming about how to script Address Book, but the link isn’t yet live at this writing.

Apple System Profiler 3.0
Apple System Profiler, in /Applications/Utilities, has turned into a Cocoa application, and in the process it has lost virtually all of its useful AppleScriptability. In the previous version, you could use AppleScript to access individual properties of your computer, such as Rated Speed, Model Name, and many others. You could also get the entire report as tab delimited text. In the new version, the usual Cocoa Standard Suite and Text Suite are included, but the only profile information you can obtain via AppleScript is the entire report as Unicode text. This report isn’t tab delimted. Worse, it is formatted for human readability with ASCII-style dashed lines for section headers, so AppleScript can’t parse it in any reasonable way.

Rumors and other indications prior to the release of Jaguar suggested that Apple System Profiler’s scriptability would be enhanced in Jaguar. Perhaps the deadline overtook this effort, and improvements to the application’s scriptability will hopefully become available in a future release.

Digital Hub Scripting
Digital Hub Scripting is a new scripting addition in /System/Library/ScriptingAdditions. It implements five actions. You can write a script containing handlers with these names, just as you do with Folder Actions, and the handlers will be triggered when the corresponding user action takes place, such as inserting a music CD or a video DVD. The other three actions recognize insertion of a picture CD, a blank CD, and a blank DVD.

DVD Player 3.2
DVD Player is in the /Applications folder. Version 3.1 introduced scriptability in March 2002, and version 3.2 appears in Mac OS X 10.2. It includes an Application class that gives you control over the size and position of the DVD controller, info, and video windows and access to many DVD features such as the current state of the DVD player (e.g., Playing, Paused), whether a DVD is inserted, the Elapsed Time and Remaining Time, and Audio Track and Chapter information, to mention only a few. It also includes several commands, including Step DVD, Stop DVD, Pause DVD, and Play DVD. This extensive scriptability is made all the more useful by the new Digital Hub Scripting scripting addition, which enables you to begin running a script containing DVD Player commands the moment a DVD is inserted.

Finder
The Finder’s Legacy suite now includes the Desktop Picture property of the Application class, moved there from the full Application class. Finder is in /System/Library/CoreServices/.

Help Viewer 2.0.1
Help Viewer is found in /System/Library/CoreServices/. It is now a Cocoa application in Mac OS X 10.2, and it has the entire Standard Suite and Test Suite that come automatically with scriptable Cocoa applications. It also continues to have a small Help Viewer suite designed to be of use to authors of Apple Help modules. In Mac OS X 10.2 this includes new commands to Go Back, Go Forward, and Go Home, emulating the functions of the buttons in the GUI, and new Handle URL and Lookup Anchor commands.

iCal 1.0
iCal 1.0 was released in September 2002, after the release of Mac OS X 10.2, but it was an integral part of the Jaguar promotion and we consider it part of Jaguar. This calendar and to-do application in the /Applications folder is scriptable. As a Cocoa application, it has the usual Cocoa Standard and Text Suites. In addition, it has Calendar, Application, Todo, and Event classes to make to-do’s and events scriptable. It also has a GetURL command, since iCal can share calendars remotely. Oddly, it includes a Create Calendar command, although it also includes the Make command from the Standard Suite and a Calendar class which should have made a hybrid Create Calendar command unnecessary.

iDVD 2.1
Apple has made much of iDVD’s scriptability. The iDVD updater was released shortly before the release of Mac OS X 10.2, and I believe it is part of Jaguar, as well. The Web site includes many useful iDVD scripts and the iDVD Companion, an AppleScript Studio application.
The iDVD Web site includes instructions for fixing iDVD 2.1 if it quits unexpectedly when you try to open its dictionary (as it did on my computer). The problem is a missing dictionary resource, which you can download and install yourself to fix the problem.

This is a Cocoa application in the /Applications folder; as such, it includes the usual Cocoa Standard and Text Suites. It also includes an iDVD suite with nine classes and five special commands to help you automate the creation of your iDVD projects.

Keychain Scripting
Keychain Scripting is a new scripting addition in /System/Library/ScriptingAdditions. It implements the Keychain Suite with commands to Lock and Unlock a keychain, and classes for Keychain, Key, AppleShare Key, Internet Key and Generic Key objects. It also implements a few Standard Suite commands and the Application class.

loginwindow 2.0.0
The loginwindow application lives in /System/Library/CoreServices. It doesn’t have a dictionary, but it does respond to Apple events. Indications are that it provides some scriptability services to the System Events application (for example, in an earlier release a bug sometimes caused commands issued to the System Events application to return the name of the loginwindow application).

I don’t know the full panoply of events to which it responds, but in Mac OS X 10.0 and newer it responds to the Log Out (‘logo’) event and, in Mac OS X 10.2, to the Really Log Out (‘rlgo’) event, both declared in the AERegistry.h header file. Because of the absence of a dictionary, you must send raw events to the application to use them. Placing <> in a ‘tell application loginwindow’ block and running the script causes a log out window to appear, and in Mac OS X 10.2 the computer logs out after two mintues if the user doesn’t intervene. Placing <> in a ‘tell application loginwindow’ block and running the script causes the computer to log out immediately without a dialog, but only if you also enclose the raw Apple event in an Ignoring Application Responses’ block otherwise, the computer won’t be able to log out until the script quits, and the script won’t be able to quit until the log out event signals completion.

Mail 1.2
Jaguar’s Mail application does not include new dictionary terminology, but Jaguar does come with new scripts in the Mail Scripts subfolder in /Library/Scripts, including scripts for importing addresses to Address Book. They appear in the Script Menu if you install it in your menu bar as described above.

Apple’s legal department must have been working overtime when Apple issued AppleCare KnowledgeBase Document 106996 shortly before the official release of Jaguar, containing this topic heading: You may use scripts in the Mail Scripts folder to import addresses or for other purposes, but they are provided AS IS. Apple does not offer technical support for these scripts.

Print Center 2.0
Print Center, in /Applications/Utilities, has become a Cocoa application. It still contains the Print Center (with a space) Suite containing three important objects: Printer, Job, and Application. These allow you to get important information about all the printers attached to your computer, including those available via printer sharing, as well as the identity of the current default printer. Among other things, you can get the current status of any printer, such as whether it is idle or printing, and a list of all the jobs queued up on any printer. The Printer class has even been expanded with a new property, Status Description. But Print Center has lost its PrintCenter (without a space) Suite, which used to contain the commands and actions Show Queue, Queue Error, Print Dialog Browser, Print Job Started, and Test Event, some of which were designed to detect when the printer began doing various things.

QuickTime Player 6.0.1
QuickTime Player 6 was introduced more than a month before Jaguar, as a separate product, and it is included in the /Applications folder in Mac OS X 10.2. Its scripting dictionary contains many new commands and classes too many to enumerate here. All of the old commands and classes appear to be intact. People who use AppleScript to control QuickTime will want to study the improvements closely.

Sherlock 3
Sherlock, in the /Applications folder, is not only all new in Mac OS X 10.2, but its role has changed dramatically. It no longer has responsibility for searching your local drives for files and their contents that function has been taken over by the new Find capability accessible via the Finder but it has enhanced abilities to find and open various Web-based information repositories, such as movies playing at a theater near you. It is now known as Sherlock 3; while the version number of the old Sherlock was 3.2, that was Sherlock 2, an older product.

Sherlock 3 is another newly Cocoa-ized application, and it has the usual Cocoa Standard Suite and Text Suite. It retains the former Find suite, but it is the same only in name. The former Search Internet command is still there, but according to the dictionary it now takes a reference instead of a list of strings as its direct parameter (this is an artifact of the way Cocoa dictionaries are currently formed; a list of strings will still work); the former In Channel optional parameter has become simply the In optional parameter; and the former Using optional parameter for saved searches is gone. The Channel class still has a Name property, but it has lost its All Search Sites property while gaining an ID property to serve as a channel’s identifier. The Application class has shrunk, retaining only the Current Channel property. The Select Search Sites command is gone along with the All Search Sites property.

The dictionary doesn’t say so, but the direct parameter is optional. The dictionary also doesn’t disclose what result is returned, but experimentation reveals that it is a list of URLs as strings, as the dictionary used to state explicitly.

Standard Additions 1.9
Standard Additions is in /System/Library/ScriptingAdditions. It has been slightly enhanced in Jaguar.

Do Shell Script now takes an optional Boolean parameter, Altering Line Endings, to turn off translation of line endings to carriage returns.

Say now takes an optional parameter Saving To, as discussed above.

Standard Additions also contains the new Folder Actions suite with the commands familiar from the classic Mac OS, as discussed above.

System Events
As discussed above, the System Events application in /System/Library/CoreServices/ has acquired many new dictionary items. Prior to Jaguar, Apple cautioned scripters to direct System Events AppleScript commands to the Finder, since System Events only included Finder-related commands. Apple’s advice has now been reversed, because System Events has now become a central focus for many scriptable features of the system available nowhere else. In addition, commands addressed to System Events reportedly run much faster in Jaguar than they did in the last release.

First, it now has the telltale Standard Suite and Text Suite of a scriptable Cocoa application.

In addition, it has a new Login Items Suite mentioned above, containing Login Item and Application classes that allow you to add and remove items from the Login Items list in System Preferences. This is the first entry in a planned long list of suites for scripting system preference panes.

It also has a new Disk-Folder-File Suite with Folder, Item, File, Disk, and Application classes apparently taken from the Finder as part of the trend to move file system scripting out of the Finder.

It includes the Folder Actions Suite with some old and some new Folder Action commands and classes.

A new Power Suite includes commands to Shut Down, Restart, and Sleep, and an associated Application class. The AppleScript 1.9.0 for Mac OS X Release Notes indicate, incorrectly, that it also includes a command to Log Out, but the loginwindow application can be scripted, using raw Apple events, to log out as described above. Due to its Cocoa underpinnings, the System Events dictionary for the Shut Down, Restart, and Sleep commands, and others, indicates that a direct parameter is required, when in fact internally none is required. To make these commands work, use any reference as a dummy direct parameter, such as a string (as in ‘restart now’). The Release Notes also indicate that these commands now automatically work in an implied Ignoring Application Responses block. This is true when you run the script as an applet; when run within Script Editor without an explicit Ignoring Application Responses block, they work only after you quit Script Editor.

A new Processes Suite includes several classes relating to processes, apparently taken from the Finder. This suite includes a new Classic property so you can tell whether a process is running in the Classic environment of Mac OS X.

Finally, a new System Events (plural) Suite contains a Do Script command and an application class. The old System Event (singular) suite is gone.

System Preferences 2.1
System Preferences, once listed as scriptable but later yanked from the list, is once again listed as scriptable this time, for real. In this release, scriptability is limited. You can count the panes, list them, list their names, and get the current pane. The Current Pane command has one awkward feature: it returns no result (instead of an empty string or Missing Value) if all panes are showing. It is located in the /Applications folder.

Scripting the System Preferences application requires it to launch. Apple plans to implement most preference pane scriptability in the System Events application so that launching System Preferences will not be necessary to script them.

Terminal 1.3
Terminal, providing the UNIX command line interface (CLI) for Mac OS X, contains two new parameters to the Do Script command in Mac OS X 10.2. The optional In parameter lets you specify the window in which to execute the command. Doing so overrides the default behavior, which is to spawn a new Terminal window. It also takes a direct parameter now: the data to be passed to the Terminal application as a command line. The With Command optional parameter is still there for the same purpose, but it is now marked as deprecated. Terminal is in the /Applications folder.

Apple’s Chris Nebel explained that the new terminology makes it easier to issue a command to Terminal and then respond to a resulting Terminal prompt by issuing a second command in the same window, with a delay command inserted between the two to deal with potential timing issues.