Nik*_*kem 23 keyboard-shortcuts keyboard-layout macos
在 Mac OS X 中,有一个键盘快捷键可以在激活的输入源之间切换。

是否可以切换到特定语言?因此,如果您有 3 种输入法,则可以有 3 个快捷方式:Ctrl-1英语、Ctrl-2西班牙语和Ctrl-3俄语。
Asm*_*mus 12
鉴于您知道要切换到的键盘布局的名称,我在 AppleScript 中想出了一个更好的解决方案。创建一个这样的函数:
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
Run Code Online (Sandbox Code Playgroud)
然后调用它
changeKeyboardLayout("English")
changeKeyboardLayout("German")
Run Code Online (Sandbox Code Playgroud)
请注意,键盘布局的名称是本地化的,即在德国系统上,上述示例需要调用“Englisch”和“Deutsch”。
我向您展示最丑陋的“解决方案”:
Ctrl-F8为Move focus to status menus定义了快捷方式。Cmd。使用AppleScript Editor和编写三个脚本,每个脚本的代码如下:
tell application "System Events"
key code 100 using control down # press Ctrl-F8
delay 0.5 # wait a bit, UI might be slow
key code 125 # press down to open the menu
keystroke "german" # name of your desired language, in my case tested using German
key code 36 # press enter
end tell
Run Code Online (Sandbox Code Playgroud)
为每种语言保存一次,切换语言名称。如果您想按不同的键,或指定与 不同的东西Ctrl-F8,请用此处的键代码替换。您还可以通过插入几个右箭头键将“输入源”菜单从其最左侧位置移动。
根据需要调用脚本,例如使用应用程序启动器(Quicksilver、Launchbar 等),或使用 Automator 将它们包装在服务中,并在System Preferences » Keyboard » Keyboard Shortcuts » Services 中为它们分配键盘快捷键。
一种选择是下载changeInput并为 shell 命令分配快捷方式,例如changeInput U.S..
您还可以使用 KeyRemap4MacBook:
<?xml version="1.0"?>
<root>
<vkchangeinputsourcedef>
<name>KeyCode::VK_CHANGE_INPUTSOURCE_HIRAGANA</name>
<inputsourceid_equal>com.apple.inputmethod.Kotoeri.Japanese</inputsourceid_equal>
</vkchangeinputsourcedef>
<item>
<name>change_inputsources</name>
<identifier>change_inputsources</identifier>
<autogen>__KeyToKey__ KeyCode::E, VK_OPTION | ModifierFlag::NONE, KeyCode::VK_CHANGE_INPUTSOURCE_ENGLISH</autogen>
<autogen>__KeyToKey__ KeyCode::H, VK_OPTION | ModifierFlag::NONE, KeyCode::VK_CHANGE_INPUTSOURCE_HIRAGANA</autogen>
</item>
</root>
Run Code Online (Sandbox Code Playgroud)
请参阅private.xml 文档。
VK_CHANGE_INPUTSOURCE_ENGLISH 在vkchangeinputsourcedef.xml 中定义。您可以从 EventViewer.app 中查看输入源的 ID。没有| ModifierFlag::NONE例如第一个设置也适用于 option-command-E。请参阅密钥代码值和预定义设置的来源。
| 归档时间: |
|
| 查看次数: |
6266 次 |
| 最近记录: |