Yosemiteの場合は若干修正が必要なようです。
1)以下のAppleScriptでなんとか動きましたが、pop up buttonの項目をmenu itemなどで選択できないので、keystrokeコマンドで強引に入力方法を選択しており、あまりスムーズな動作は期待できないです。 実行時にメッセージが表示されると思いますが、システム環境設定>セキュリティとプライバシー>アクセシビリティで、スクリプトエディタ.appの項目にチェックを入れてやる必要があります。
tell application "System Preferences"
activate
set the current pane to pane id "com.apple.preference.keyboard"
reveal anchor "InputSources" of pane id "com.apple.preference.keyboard"
end tell
tell application "System Events"
tell process "System Preferences"
tell window 1
tell tab group 1
tell scroll area 1
tell table 1
tell (rows whose value of static text 1 of UI element 1 is "日本語") # or "Japanese"
set selected to true
end tell
end tell
end tell
tell scroll area 2
tell pop up button 2 -- Yosemite
-- properties
set focused to true
delay 0.5
keystrokespace
delay 0.5
key code 125 # down arrow "かな入力"
--key code 126 # up arrow "ローマ字入力"を設定する場合
keystrokereturn
end tell
end tell
end tell
end tell
end tell
end tell
-- tell application "System Preferences" to quit # システム環境設定を終了する場合
2)私は、普段Macを使う際に、入力方法をローマ字入力とかな入力との間で切り替える操作は滅多に行わないのですが、よろしければ、どのような状況でこのような操作をする必要があるのか、教えて頂ければ幸いです。
3)サポートコミュニティの皆様、もっと良い方法があれば教えて下さい。 宜しくお願い申し上げます。