Assign Shortcut Keys to Script Menu AppleScripts
The macOS has the ability to assign menu shortcut keys in pretty much every application, including AppleScripts listed in the Script Menu of the Media apps. Here's how to do it.
(Hey! If you don't want to do-it-yourself, FastScripts from Red Sweater Software provides the ability to quickly and simply add and manage AppleScript keyboard shortcuts. I highly recommend it.)
Set Up Your System Settings
Note: This will only work with scripts that have been installed in an app's "Scripts" folder such that a script appears in the app's Script menu. See the "Read Me" .rtfd doc that accompanies each script download for instructions on installing or see the online FAQ.
Quit the app. You can't attach a keyboard shortcut to an application if it is running. (Actually, I'm not quite sure of this old rule anymore. Even so, it's a good practice.)
Open your System Settings and click on "Keyboard" in the left column. Click on the "Keyboard Shortcuts..." button in the panel that appears. A new panel will open with a list of options on its left side. Click "App Shortcuts..."
If the app you want to use the script with is not already listed, click on the "+" button and in the Application pop-up of the sheet that appears, select the appropriate app.
In the "Application" popup, select the appropriate app. Enter the name of the AppleScript to which you want to assign a keyboard shortcut exactly as it appears in the Script Menu as the "Menu Title". In the "Keyboard Shortcut" field, press the combination of keys you want to use for the shortcut.
Click the "Done" button and quit System Settings.
The next time you start the app, look in its Script Menu. The shortcut you assigned will be displayed adjacent to the name of the Script you assigned it to, just like a real menu shortcut! That's because it is a real menu shortcut.
For more details, search your Mac Help for "Setting custom keyboard shortcuts for applications".
OF COURSE, this isn't just for assigning shortcuts to items in the Script menu. You can also assign keyboard shortcuts for menu commands that don't already have a shortcut, such as "Check for Available Downloads...", "Export Library...", "Check for Updates...", and so on. (And in this blog post, I describe a cool trick to unambiguously assign shortcuts to menu items in sub-menus.)
If you assign a keyboard shortcut which an app is already using you may get mixed results. For example, I assigned Shift-Command-Nwhich is Music's "New Playlist from Selection" shortcutto a script and the script fired (the script actually does the same thing as "New Playlist from Selection" but asks for a new playlist name first). But it wouldn't let me assign Command-A, the universal "Select All" shortcut. It also knows what keys you have assigned already, and it will warn you if you try to enter a duplicate shortcut.
As far as using the F keys: I could only get combinations that included Command to work. No problem, though. There are still hundreds of key combinations available.
Check out the Missing Menu Commands page for some mini-scripts that work great with shortcuts.
Here are some suggested scripts to which you may want to assign a shortcut:
- Play Random Album v4.1
[ For Music ] Creates and plays playlist using tracks from album chosen at random
⇨ Play Random Album 3.1 for pre-macOS 10.15 and iTunes.
- Search-Replace Tag Text v7.3
[ For Music/TV ] Perform search-and-replace on text in your choice of tags
⇨ Search-Replace Tag Text 5.5 for pre-macOS 10.15 and iTunes.
- Remove n Characters From Front or Back v7.2
[ For Music/TV ] Delete characters from the beginning or ending of selected tracks' name, artist, album, more
⇨ Remove n Characters From Front or Back 5.10 for pre-macOS 10.15 and iTunes.
- Clipboard as Artwork for Selection v2.1
[ For Music ] Copy clipboard image directly to selected tracks as artwork
- Is Artwork Embedded v2.1
[ For Music ] Detects if a track's file's metadata contain image information
⇨ Is Artwork Embedded 1.2 for pre-macOS 10.15 and iTunes.
- Delete Lyrics v3.1
[ For Music ] Delete lyrics from the selected tracks
⇨ Delete Lyrics 2.0 for pre-macOS 10.15 and iTunes.
- Size of Artwork v3.1
[ For Music/TV ] Display the width x height of selected track's artwork
⇨ Size of Artwork 2.0 for pre-macOS 10.15 and iTunes.
- Clipboard to Lyrics v3.0
[ For Music ] Copy clipboard text to lyrics tag of playing or selected track(s)
⇨ Clipboard to Lyrics Scripts 2.0 for pre-macOS 10.15 and iTunes.