システムイベントを使って入力モードを変更する [AppleScript辞書はつくれるか?]
(* 画面右上のプルダウンメニューである"SystemUIServer"を操作する. メニューの中から該当するアイテムを探し、疑似クリックをする。 *)
my inputmode("ひらがな")
on inputmode(thelanguage) set flg to false tell application "System Events" tell process "SystemUIServer" --|SystemUIServerの呼び出し| launch
--|メニューバーにある全てのメニュー名の取得| tell menu bar 1 set menuBerItem to name of (every UI element) --|それぞれのメニューの中のアイテムを順に取得| repeat with manuNo from 1 to (count of menuBerItem) tell menu bar item manuNo tell menu 1 try set menuItem to name of (every UI element) --|該当するアイテムを探す| set itemNo to 0 repeat with itemNo from 1 to (count of menuItem) if (item itemNo of menuItem) contains thelanguage then try --|メニューが見つかった場合に疑似クリック| click menu item itemNo set flg to true end try exit repeat end if end repeat end try end tell end tell if flg then exit repeat end repeat end tell if flg then click menu bar item manuNo of menu bar 1
end tell end tell
return flg
end inputmode |
コメント 0