oreilly.comSafari Books Online.Conferences.


AddThis Social Bookmark Button

Hit-and-Run: Launching AppleScripts with Keyboard Shortcuts
Pages: 1, 2, 3, 4, 5

If you want to use global keyboard shortcuts for launching your AppleScripts, FastScripts simply is the most Mac-like way to achieve this. The software is available from Red Sweater Software's website, costs $14.95, and comes with a 30-day trial period. If you can make do without the Recent Scripts menu and need no more than ten keyboard shortcuts, you can opt for the free FastScripts Lite.

While FastScripts is perfect for assigning keyboard shortcuts to AppleScripts, there are two useful automation-related things it cannot do, yet: it does not list Automator workflows and you cannot use it to launch an AppleScript droplet with the current Finder selection. To integrate these two techniques in your automation endeavors, you should consider using an advanced application launcher like Quicksilver.

UPDATE: Starting with release 2.2.3, FastScripts supports folder aliases, so that, by placing an alias to <your home folder>/Library/Workflows in the <your home folder>/Library/Scripts folder, your workflows also show up in FastScripts's menu. According to the developer, future versions of FastScripts may automatically list Automator workflows.

App(leScript) Launcher on Steroids: Quicksilver

You can choose from a range of application launchers for Mac OS X, but Blacktree's Quicksilver— which is all the rage on productivity-oriented websites right now, and deservedly so — is in a class all by itself.

Quicksilver compiles a catalog of objects, including files from a set of configurable locations on your Mac's harddrive, bookmarks from Safari, albums/artists/songs in iTunes, etc. To select an object in Quicksilver's main window (Figure 6), you type in a few letters, and Quicksilver will display a list with matching objects, preselecting what it considers the best match. With time, Quicksilver learns which letter combinations you use for which objects, and you can also define letter combinations manually, e.g., "M" for Mail, "S" for Safari, "SE" for Script Editor, or "MDC" for the Mac DevCenter website.

After selecting an object, you select an action in the same way, some of which may involve a target that, again, is selected the same way—e.g., for moving files to a folder, or opening a file with an application.

figure 6
Figure 6. Quicksilver's main window, ready to open the Pause iTunes script file with Script Debugger. Note how few key strokes -- PAUSE <tab> OW <tab> SD -- this requires, especially for selecting the action and target, and think about how much navigation in the Finder it would require to drag-n-drop the file onto the application's icon.

The real beauty, however, lies in Quicksilver's expandability. There are countless plugins available that expand the searchable objects and actions, resulting in a very seamless workflow encompassing just about anything you do with your data on your computer. OK, enough praise for Quicksilver already. Let's get back to our topic of keyboard shortcuts.

In order to have Quicksilver find our AppleScripts, we must make sure that they are included in Quicksilver's catalog of objects: open Quicksilver's Catalog preferences, select the Scripts section, and ensure that both "Scripts (All Users)" and "Scripts (User)" are checked. If not, check both and click on the "circular arrow" next to the "I" button at the bottom of the window to make Quicksilver rescan the respective folders so they are available to us right away (otherwise, they'd be available after Quicksilver's next regular rescan interval as defined by the "Rescan" pop-up menu). (See Figure 7.)

figure 7
Figure 7. Make sure that the AppleScript folders are included in Quicksilver's object catalog.

A keyboard trigger to fire Our AppleScript

Now, let's assign a keyboard shortcut to our "Pause iTunes" script, say Control-M.

As a piece of advice, creating global shortcuts that do not contain the Command key helps minimize the risk of a conflict with existing keyboard combinations in applications, because there are only very few applications, like Terminal or some text editors, that use keyboard shortcuts without the Command key.

In Quicksilver's Triggers preferences, select the Custom Triggers on the left. Now click the plus sign and choose HotKey from the menu. In the dialog sheet that pops up, start typing "Pause iTunes" in the upper field until the "Pause iTunes" script is selected. Usually, the action field should already show "Run." If it doesn't, tab into it and type "Run." Hit Return to add this task to the Triggers list. (See Figure 8.)

figure 8
Figure 8. Defining the Trigger task for running the Pause iTunes script.

Pages: 1, 2, 3, 4, 5

Next Pagearrow