ã¡ãã¥ã¼ã¨ã¯ã¹ãã©ã確å®ã«æä½ããGUIã¹ã¯ãªããã£ã³ã°
ãã¶ãããã¹ã¯ãããå³ä¸ã®ã¡ãã¥ã¼ãã¼ã«ã¯ãããã¤ãã®ã¢ã¤ã³ã³ã¡ãã¥ã¼ã並ãã§ããã¨æãããã®ä¸ã§ããããã»ã¹å"SystemUIServer"ã管çããã¢ã¤ã³ã³ã¡ãã¥ã¼ã¯ãmenu extra*1ã¨å¼ã°ãã¦ãããï¼control-F8ã¨ç¢å°ãã¼ââââã§æä½ã§ããã¢ã¤ã³ã³ã¡ãã¥ã¼ï¼
ä»ã¾ã§ãã¡ãã¥ã¼ã¨ã¯ã¹ãã©ãAppleScriptã§æä½ããæã¯ãã¢ã¤ãã å称ã§ã¯ã¢ã¯ã»ã¹ã§ããªãã¨æãè¾¼ãã§ãã¦ãå°ãã¢ã¤ãã çªå·ã§ã¢ã¯ã»ã¹ãã¦ããã
tell application "System Events"
tell process "SystemUIServer"
click menu bar 1's menu bar item 7
end tell
end tell
ä¸è¨ã®ã¹ã¯ãªããã¯ãèªåã®MacBookç°å¢ã§ã¯ã¹ã¯ãªããã¡ãã¥ã¼ãã¯ãªãã¯ããçµæã¨ãªããããããããã¯ãã®æã®èªåã®MacBookç°å¢éå®ã®æä½çµæã§ãããã¡ãã¥ã¼ã¨ã¯ã¹ãã©ã表示ããã¦ããåæ°ã並ã³é ã«ãã£ã¦ã¯å ¨ãéã£ãæä½ã«ãªã£ã¦ãã¾ã...ãèªåãå«ãã¦ãä¸è¨ã®ã¹ã¯ãªããããã®ã¾ã¾å©ç¨ãã訳ã«ã¯ããããç®çã¨ããã¡ãã¥ã¼ã¨ã¯ã¹ãã©ã®ã¢ã¤ãã çªå·ã調ã¹ã¦ãç¾ç¶ã«åããã¦ãä¿®æ£ããå¿ è¦ãããã®ã ã
ç¶æ³ã«ãã£ã¦ãã®é½åº¦ãä¿®æ£ããªãã¨åããªããããªã¹ã¯ãªããã¯æ¥µåé¿ããããçæ³ã¯ãã¢ã¤ãã å称ã§çµ¶å¯¾æå®ããæ¹æ³ãªã®ã ã*2ãã®ãããªæ¹æ³ããªããã®ã常æ¥é ãé ã®çé ã§èãã¦ããããæè¿ä½ãå¥ã®æ¤ç´¢ä¸ã«å¶ç¶ãè¦ã¤ããï¼ï¼å¬ããï¼
è±èªã®æ å ±ãªã®ã§ãæ®æ®µãªããè±èªå«ããªèªåãæ°ã«ãçããã¯ããªãã®ã ãããRe: Accesing menu bar items.ãã¨ããã¿ã¤ãã«ãè¦ãç¬éãèå³ãããããã¦ãã¾ã£ããèªããªããªãã«ä¸æ°ã«èªãã§ãã¾ãã¨ãã¾ãããèªåãæ±ãã¦ããæ å ±ã ã£ããç´ æ´ãããï¼
ä½æ¥ç°å¢
- MacBook OSX 10.6.2
- AppleScript ã¨ãã£ã¿ 2.3(118)
- AppleScript 2.1.1
click_menu_extra(menu_path)ã®å®ç¾©
...ã¨ãããã¨ã§ãæ©éãèªåã®AppleScriptã©ã¤ãã©ãªï¼_gui.scptã« click_menu_extra ã¡ã½ããã追å ãã¦ã¿ãã
--ã¢ã¤ã³ã³ã¡ãã¥ã¼ï¼ã¹ãã¼ã¿ã¹ã¡ãã¥ã¼ï¼ãé常ã®ãã¹ã§æå®ã§ããããã«ãªã£ã
--click_menu_extra("AppleScript/Script Editor Scripts/About these scripts...")
--click_menu_extra({"AppleScript", "Script Editor Scripts", "About these scripts..."})
on click_menu_extra(menu_path) if menu_path is "" then
error "menu_path ãå ¥åããã¦ãã¾ããã"
end if
set mp to split(menu_path, "/") tell application "System Events"
tell process "SystemUIServer"
set frontmost to true
click (menu bar 1's first menu bar item whose attribute "AXDescription"'s value is (mp's item 1)) repeat with i from 2 to mp's length
click (result's menu 1's menu item (my number_from(mp's item i))) end repeat
delay 0.1 --é£ç¶ãã¦ã¡ãã¥ã¼ãæä½ããæãã²ã¨å¼å¸å¿ è¦
end tell
end tell
end click_menu_extra
on split(sourceText, separator) if sourceText = "" then return {} set oldDelimiters to AppleScript's text item delimiters
set AppleScript's text item delimiters to {separator} set theList to text items of sourceText
set AppleScript's text item delimiters to oldDelimiters
return theList
end split
on number_from(str) try
str as number
on error
str
end try
end number_from
ã¡ãã¥ã¼ã¨ã¯ã¹ãã©ã®å称ã¯ã以ä¸ã®ã¹ã¯ãªããã§ç¢ºèªã§ããã
tell application "System Events"
tell process "SystemUIServer"
menu bar 1's menu bar items's attribute "AXDescription"'s value
end tell
end tell
--çµæ
(* {"iStat menus Temperatures", "iStat menus Network", "iStat menus Memory", "iStat menus CPU", "time machine", "Sync", "AppleScript", "bluetooth", "ã·ã¹ãã ãµã¦ã³ãé³é", "AirMac Menu Extra", "text input", "ããããªã¼ã¡ãã¥ã¼ã å é»æ¸ã¿ .", "user"} *)
- whoseãã£ã«ã¿ã®ä½¿ãæ¹ã¯ç¥ã£ã¦ããã
- ã¡ãã¥ã¼ãã¼ã¢ã¤ãã ãattributesãæã£ã¦ãããã¨ãç¥ã£ã¦ãããï¼UIElementInspector.appããèªã¿åã£ã¦ï¼
- ã ãããéå»ã«whoseã¨attributesãå©ç¨ãã¦è©¦ãã¦ã¿ãè¨æ¶ã¯ãããããã¾ãã§ããªãã£ã...ã
- ãã¶ããwhoseãã£ã«ã¿ã®çµæãããªã¹ãã¨ãã¦è¿ããããã¨ã«æ°ä»ããªãã¦ãã¨ã©ã¼ãåºãã¦ããã®ã ã¨æãã
- ããããã®æã¯ãã¡ãã¥ã¼ã¨ã¯ã¹ãã©ã®attributesã§ã¯ã¢ã¯ã»ã¹ã§ããªãã¨æãè¾¼ãã§ãã¾ã£ãã®ãããããªãã
-
-
- ããã«ãã¦ãããããããªã¼ã¡ãã¥ã¼ã å é»æ¸ã¿ .ãã¨ããDescriptionï¼è¨è¿°, åè¿°, 説æï¼ã«ã¯å¹»æ» ãããï¼çµ¶å¯¾æå®ã¨ããç®çã«ããã¦ã¯ï¼
- Descriptionï¼è¨è¿°, åè¿°, 説æï¼ãªã®ã ãããããããªã¼ã¡ãã¥ã¼ã®æ¹ãæ£ããã®ãããããªãã...ã
- 試ãã«ãé»æºã¢ããã¿ãæãã¦ã¿ãã¨ãããããªã¼ã¡ãã¥ã¼ã æ®ãæéãè¨ç®ä¸... .ãã«å¤åããã
-
ã¡ãã¥ã¼ã¨ã¯ã¹ãã©ä»¥å¤ã®ã¢ã¤ã³ã³ã¡ãã¥ã¼ã®æä½
- ã¡ãã¥ã¼ã¨ã¯ã¹ãã©ä»¥å¤ã®ã¢ã¤ã³ã³ã¡ãã¥ã¼ã®ç¢ºå®ãªæä½ã«ã¤ãã¦ã¯ããæä¸ãã
- ç¾ç¶ã¯cliclickã³ãã³ãã«é ¼ã£ã¦ããã
- ã·ã³ãã«ã«ã¯ã³ã©ã¤ãã¼ã§æ¸ããã¨ããã¯å¤§å¥½ããªã®ã ã...
- ãã¹ã¯ãããã®ç¶æ³ã®å¤åã«å¯¾å¿ããã®ã極ãã¦å°é£ãªã®ã ã
ããããã¦ãèªåãç¥ããªãã ãã§ãä¸çã®ã©ããã«ç´ æ´ãããæ¹æ³ãããã®ãããããªã...ãï¼ç¥ãããã§ãï¼ï¼
*1:/System/Library/CoreServices/Menu Extras/ ãã©ã«ãã«å ¥ã£ã¦ããã®ã§ã
*2:ã¢ã¤ãã "çªå·"ã¯ç¸å¯¾æå®ã¨èãã¦ã¿ããããããã¢ã¤ãã "å称"ãè¨èªç°å¢ã«ãã£ã¦å¤åãã¦ãã¾ãå¯è½æ§ãããã®ã§ãå¿ ããã絶対æå®ã¨ã¯è¨ããªãããã