Loading

Mac切换到指定输入法

系统默认的输入法切换方式,本质是“切换到下一个输入法”或“切换到上一个输入法”,常常是输错了字符才发现选错了输入法,误选输入法的几率很大,容易干扰工作节奏。
尤其在开发工作中,窗口之多,中、英文切换之频繁,能直接指定输入法是很有必要的。

实现方法,使用 Keyboard Maestro 绑定快捷键,执行切换输入法的脚本。

脚本安装(InputSourceSelector)

仓库地址: Github

下载后,进入脚本根目录,执行

make

生成可执行文件 InputSourceSelector,将其放到 用户目录 ~/

Keyboard Maestro 设置快捷键

可能会用到命令(更多命令在文末):

// 切换到ABC输入法
~/InputSourceSelector select com.apple.keylayout.ABC

//切换到双拼输入法
~/InputSourceSelector select com.apple.inputmethod.SCIM.Shuangpin

//切换到拼音输入法
~/InputSourceSelector select com.apple.inputmethod.TCIM.Pinyin

//所有可见的输入法名称,可以通过该命令查看
~/InputSourceSelector list-enabled 

Keyboard Maestro的设置很简单,就是触发快捷键,执行shell动作。
建议选用的快捷键不要有手指大幅度的移动,不然很影响效率。
配置参考如下,

InputSourceSelector的相关命令

Usage

$ InputSourceSelector [command]
[command] is described below.

Commands

  • list Lists currently installed input sources.
  • list-enabled Lists currently enabled input sources.
  • current Prints currently selected input source.
  • current-layout Prints currently used keyboard layout.
  • enable [input source ID] Enables specified input source.
  • **disable [input source ID] **Disables specified input source.
  • select [input source ID] Selects specified input source.
  • deselect [input source ID] Deselects specified input source.

[input source ID] is one of the input source IDs printed by list,list-enabled,current,current-layout commands, such as com.apple.keylayout.US or com.apple.inputmethod.Kotoeri.Japanese.

posted @ 2022-05-28 11:03  逆行  阅读(361)  评论(0编辑  收藏  举报