SSブログ

メニューバーを簡単に操作 [AppleScript辞書はつくれるか?]

画面上部のメニューバーを簡単に使用するためにちょっと作ってみた。

例えば、『移動>ダウンロード』をクリックしたい場合...

ss2.jpg


と選ぶところをスクリプトでやらせてみる

ss1.jpg


スクリプト全体

(* 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 {"移動", "ダウンロード"}

の部分を変更してやれば、いろいろ使える。

nice!(1)  コメント(0) 
共通テーマ:パソコン・インターネット

nice! 1

コメント 0

コメントを書く

お名前:
URL:
コメント:
画像認証:
下の画像に表示されている文字を入力してください。

この広告は前回の更新から一定期間経過したブログに表示されています。更新すると自動で解除されます。