« AppleScript autoresponder in Snow Leopard's Mail.app | Main | Dream a little dream of someone »

Keyboard shortcuts for AppleScripts in Snow Leopard?

| 10 Comments

In Mac OS X 10.6 Snow Leopard, the keyboard-shortcuts system has been enhanced in various ways. But now I can't seem to assign a shortcut to an AppleScript.

I also can't find any information about this online—in particular, I can't figure out whether it's user error on my part or a change in the OS. Articles I've looked at have fallen into any of several categories:

  • Written years ago, when AS filenames indicated keyboard shortcuts.
  • Written for Leopard, when assigning keyboard shortcuts to scripts worked just like assigning keyboard shortcuts to other menu items.
  • Recommendations to use Quicksilver, Mail Act-On, or FastScripts.

I'd be willing to use one of those utilities, but before I download and install and learn to use a third-party system, I'd like to find out whether the capability I need is built into the operating system, as I think it was in previous versions. I know that Quicksilver is supposed to be the perfect all-purpose tool for every occasion, but for my particular purposes right now it seems kind of like swatting a fly with a hand grenade, or fixing a toaster by remodeling the kitchen.

As a side note, I was rather surprised to be unable to find any page that compares and contrasts Quicksilver and Mail Act-On. I know that Quicksilver does a bunch of stuff that's way outside the scope of Mail Act-On; I'm not clear on whether Mail Act-On does anything that Quicksilver doesn't (or does anything better). Likewise with FastScripts: is there a reason to use that instead of (or in addition to) Quicksilver, other than Quicksilver's general vastness?

Anyway, my main question here is: should it work to assign keyboard shortcuts to AppleScripts (for Mail.app) in Snow Leopard? If so, is there anything special I need to do to make that work? I carefully checked the spelling of the script name two or three times, and tried a couple of different script names, and tried both an app-specific script and a user-specific script, but couldn't get the keyboard shortcut to show up in the script menu. (And yes, I quit Mail and restarted it after each attempt.)

10 Comments

I am very much interested in this... actually have the same exact problem. I have an applescript that sends messages to the app Hit List - and works perfectly in snow leopard when ran from the applescript menu list. I am just unable to assign a keyboard shortcut to it.


My current semi-solution is to use Quicksilver, but it's not a solution I'm entirely happy with.


Create an Automator "Service" which runs an AppleScript


I'm irritated that I couldn't just assign a keyboard shortcut to the AppleScript, but creating an Automator "Service" did the trick.


I would also wish that apple did make it possible to easily assign shortcuts to applescripts - especially since the automator solution seems to be quite slow.

At least I hopt that Apple will optimize the process even further. Another issue that annoys me, is that I cannot search for the service that I want to make a shortcut for - and sometimes it takes rather long time to locate the service.

In this_service, it was possible to assign a shortcut directly from the application - I hope that Apple will implement this possibility in Automator. Unfortunately, I suspect they wait until 10.7...


I used Automator to run a shell script but can't assign a shortcut key to it when I select it under "Services" in the keyboard shortcut menu. I also can't find any good documentation on this. Is it broke in Snow Job... I mean Snow Leopard?


I know this is rather old, but I thought I would throw this out there. I'm not sure if this is the same for all apps or just a handful (but I think it is a longstanding Apple thing). Anyway, if you want keyboard shortcuts for your scripts in the Applescript menu, you need to add them to the file name. So each meta key has an single letter abbreviation, s is for shift, o is for option, c is for control, and m is for command. So if you want your script to be triggered by CTRL-OPT-V then when you put your script into the proper folder, you name it: Script Name\cov
Or for SHIFT-CMD-M: Script Name\smm
If you wanted CTRL-M you could use \cm. Since you can't have the script triggered with only two meta keys, the m is used to mean the letter m and not the command key. Hope this helps.


Thanks, but my understanding is that that approach no longer works in recent versions of Mac OS. (That's what I was referring to in the part of the entry where I said "Written years ago, when AS filenames indicated keyboard shortcuts.") But I would be happy to be wrong about this.


Jump ahead 5 years. I'm running Yosemite {10.10). Michael's comment is as true today as it was in 2010. You *can* assign keyboard shortcuts to AppleScripts by using the backslash character (\) and a specific arrangement of letters as part of the filename of the script, like so:

script-name\smM.scpt assigns SHIFT-CMD-M (the letter M)
script-name\scM.scpt assigns SHIFT-CTRL-M
script-name\soM.scpt assigns SHIFT-OPTION-M
script-name\cmM.scpt assigns CTRL-CMD-M
script-name\coM.scpt assigns CTRL-OPTION-M
script-name\moM.scpt assigns CMD-OPTION-M

The letter M isn't the only keystroke this works with. Note: It is possible to conflict with OS X system-wide and app-specific keyboard shortcuts.



Thanks! I no longer need to do this (I use Mail Act-On now), but good to know for future reference.

(And sorry your comment got stuck in moderation for a couple weeks.)


Post a comment