インプットメソッド切替

  • むちゃ遅
  • むちゃ環境依存(日頃、cmd+spaceを使用してる人向け)


より詳しくは、

defaults -currentHost read com.apple.HIToolbox AppleCurrentInputSource

して"Input Mode"で種別を判断する。

applescript

property ROMAN : "smRoman"

set IM to do shell script "defaults -currentHost read com.apple.HIToolbox AppleKeyboardScript"
if (IM is not equal to ROMAN) then
  tell application "System Events"
    keystroke " " using command down
  end tell
end if

shellscript版

#!/bin/sh

IM=`defaults -currentHost read com.apple.HIToolbox AppleKeyboardScript`

if [ $IM != 'smRoman' ]; then
osascript << EOF
tell application "System Events"
  keystroke " " using command down
end tell
EOF
fi