Run an AppleScript by using a keyboard shortcut

I need to run an AppleScript using a keyboard shortcut. How can I do that?

I think about

  1. Save AppleScript in textual format.
  2. Use Keyboard Maestro to launch 'osascript' to run the script when the matching keyboard shortcut is called.

What do you think? Is there better way to go?


Solution 1:

A program like Keyboard Maestro can do exactly as you said, but instead of saving the AppleScript as just regular text you can save it as a script (.scpt) and just pass the path to osascript.

A program that I've used off and on that is designed to do this specifically is Red Sweater Software's FastScripts. It's free for up to 10 keyboard shortcuts. Otherwise I've just used LaunchBar (while others would recommend other app launchers)

Solution 2:

I do it with Quicksilver to launch a script that opens a Terminal window at the same place the foremost Finder window is.

Triggers -> [+] -> HotKey, then select your script, and choose the "Execute" action.

It's probably similar to using Keyboard Maestro, and said software might be simpler. Though, I already had Quicksilver installed when I did this, so reusing it was better.