メニューバーを簡単に操作 [AppleScript辞書はつくれるか?]
(* modeNo = | 1:メニュークリックの実行 / 2:プロセス名リストを得る | *) set modeNo to 1
if modeNo = 1 then set processName to "Finder" set menuList to {"移動", "ダウンロード"} --activate application processName my clickMenu(processName, menuList)
else if modeNo = 2 then set ProcessList to my everyProcess() log ProcessList end if
on clickMenu(processName, menuList) try set processName to processName as text on error return false end try if processName is "" then return false set commandText to "tell application \"System Events\"" & return set commandText to commandText & "click " set c to count of menuList if c > 1 then repeat with i from 2 to c set obj to item i of menuList set commandText to commandText & " menu item \"" & (item i of menuList) & "\" of menu 1 of " end repeat end if set commandText to commandText & "menu bar item \"" & (item 1 of menuList) & "\" of menu bar 1 of " set commandText to commandText & "application process \"" & processName & "\"" & return set commandText to commandText & "end tell"
log commandText run script commandText end clickMenu
on everyProcess() tell application "System Events" set ans to name of every process whose visible is true set objList to "" repeat with obj in ans set objList to objList & obj & return end repeat end tell return objList end everyProcess |
set processName to "Finder" set menuList to {"移動", "ダウンロード"} |
コメント 0