AppleScript_ The Definitive Guide - Matt Neuburg [11]
Similarly, Microsoft Entourage , an email application, lacks any menu item or keyboard shortcut that truly deletes an email message. Deleting a message that's already in the trash folder (called "Deleted Items") does truly delete it, but deleting any other message merely moves it into the trash folder. This is spectacularly annoying when, for example, you are ready to delete spam messages that have been categorized into the Junk E-Mail folder. But Entourage is scriptable, and it has a Script menu to which you can add your own scripts. So I've written a script to delete all currently selected messages:
tell application "Microsoft Entourage"
display dialog "Really delete selected messages completely?"
set theMessages to current messages
try
delete theMessages
delete theMessages
end try
end tell
Some scriptable applications provide a means for customization at an even deeper level, by letting you modify what happens when you choose one of the application's own menu items or perform some other action in that application. For example, the Finder can be set up with Folder Actions that take over automatically when you do things such as move a file into a certain folder. (See "Automatic Location" in Chapter 2 and "Folder Actions" in Chapter 26.)
Combining Specialties
Different applications are good at different things. Most users don't perform all tasks in a single application. For example, in a word processor, you wouldn't expect to perform extensive editing of pictures: a document might include pictures, but you'd create and edit them in some other program, and then incorporate them into the word processing document. That's how it should be, and that's how users typically like it, especially on Mac OS X where (in contrast to previous systems) there is no significant penalty to running several applications at the same time. "Swiss Army knife" programs that try to be all things to all users generally seem bloated with unnecessary features (such as Microsoft Word, with its Photoshop-like "graphics enhancement" features).
When it comes to assisting applications to combine their separate specialties, AppleScript really shines. Thanks to AppleScript, data can be moved back and forth between applications so that each can operate upon it in the appropriate manner. The result is a workflow in which multiple applications are coordinated, often without the intervention or even the awareness of the user.
Take, for example, SpamSieve . This superb application uses Bayesian algorithms to distinguish between spam and nonspam email messages with astonishing accuracy—far better than those email client programs, such as Entourage and Apple Mail, that include spam filtering of their own. But SpamSieve is not itself an email client. So in order to filter out spam as your email client application receives it, that email client application and SpamSieve must cooperate. The email client receives the mail messages, and hands them over to SpamSieve for evaluation; if SpamSieve