After 4.5 years of struggling with OS X’s input source menu, I have finally figured out how to bind key combinations to selection of specific input sources (read: English, traditional Chinese through Pinyin, Japanese Hiragana, …). Here are the steps:
- Note the specific names of the input sources on the input menu you want to use. Mine, for example, are “U.S.”, “Russian”, “Pinyin – Traditional”, “Hiragana”, and so forth
- Install Quicksilver.
- Open Script Editor (Spotlight will find it).
- Within Script Editor, add the contents
on changeKeyboardLayout(layoutName) tell application "System Events" to tell process "SystemUIServer" tell (1st menu bar item of menu bar 1 whose description is "text input") to {click, click (menu 1's menu item layoutName)} end tell end changeKeyboardLayout changeKeyboardLayout("your_input_source_name")
where
your_input_source_name
is replaced with the name of one of your input sources. For example, I might usePinyin - Traditional
. Note that you have to get the name of the input source EXACTLY right. - Save this script as
your_input_source_name.scpt
in a location of your preference, where you replaceyour_input_source_name
with a mnemonic string of your preference (I might just usechinese-traditional
) . - Open Quicksilver through Spotlight. Push ⌘’ to open the Triggers window.
- On the bottom of the Triggers window, hit “+” and choose HotKey to add a HotKey binding.
- For “select an item”, type in the name of your saved script until Quicksilver finds it.
- For “Action”, just leave it as “Run”.
- Don’t put anything for Target. Click Save.
- You’ll now have a new item in the Triggers window called
Run Script: your_input_source_name.scpt
. Now double-click on the “Trigger” column of that item, click “Settings” in the new sub-window popping out to the left, click in the Hot Key window, and type in a hot key combination (e.g., I might use ^⌘T). - Repeat steps 4-11 for each input source for which you want a keyboard shortcut.
Kudos to Asmus who posted the very simple AppleScript code used above at this link.
Post a Comment
You must be logged in to post a comment.