GUIã¹ã¯ãªããã£ã³ã°ã§ä½¿ããããªãéå ·
AppleScriptã«å¯¾å¿ãã¦ããªãã¢ããªã±ã¼ã·ã§ã³ã§ããOSãæä¾ããGUIãæå®ãã¦ã³ã¼ãã£ã³ã°ã«ãã£ã¦æä½ã§ããGUIã¹ã¯ãªããã£ã³ã°ã¯ããã¸ã便å©ããã ããæªç¥ã®GUIã®æ§é ãç解ãã¦ããããAppleScriptã®ææ³ã§æå®ããã®ã¯çµæ§ããã©ãã¨ãããããã
GUIã調ã¹ã
AppleScriptã¨ãã£ã¿ã§ç¢ºèª
- åºæ¬ã¯ãå°éã«AppleScriptã¨ãã£ã¿ã§ä»¥ä¸ã®ãããªã¹ã¯ãªãããå®è¡ãã¦ããã®çµæããGUIãæå®ããã³ã¼ãã確èªããã®ã確å®ã
- 以ä¸ã¯ãSafariã®ã¡ãã¥ã¼ï¼è¡¨ç¤º >> ããã¹ãã¨ã³ã³ã¼ãã£ã³ã° >> Unicode (UTF-8) ã®GUIã解æãã¦ããä¾ã
tell application "System Events"
tell process "Safari"
set frontmost to true
UI elements
end tell
end tell
{window "è¨äºãæ¸ã - ã¶ãªã¬ããè¦ã¦ãã...ã" of application process "Safari" of application "System Events", ¬ menu bar 1 of application process "Safari" of application "System Events"}
Automatorã§è¨é²
- Automatorã§è¨é²ãã¦ãè¨é²ãããã¤ãã³ããä¸ã¤é¸æãã¦ãã¯ã¼ã¯ããã¼ã¨ãã¦ããããããã¨ãGUIã¹ã¯ãªããã£ã³ã°ãªAppleScriptã¨ãã¦å±éãããã
- æ£å¸¸ã«åããªããã®ãããããæ軽ã«AppleScriptã³ã¼ãã確èªã§ããã®ã§ä¾¿å©ã
-以ä¸ããã©ãã°ï¼ãããããã¦ãã¤ãã³ãããå±éãããAppleScriptãï¼ä¸å³ãªã¬ã³ã¸è²ã®æ å ï¼
on run {input, parameters} -- Unicodeï¼UTF-8ï¼
delay 3.776055
set timeoutSeconds to 2.0
set uiScript to "click menu item 8 of menu 1 of menu item 17 of menu 1 of menu bar item 5 of menu bar 1 of application process \"Safari\""
my doWithTimeout(uiScript, timeoutSeconds) return input
end runon doWithTimeout(uiScript, timeoutSeconds) set endDate to (current date) + timeoutSeconds
repeat
try
run script "tell application \"System Events\"\r" & uiScript & "\rend tell"
exit repeat
on error errorMessage
if ((current date) > endDate) then
error "Can not " & uiScript
end if
end try
end repeat
end doWithTimeout
UIElementInspector.app
å°ãæ £ãã¦ããã¨ããã£ã¨ä½ç³»çã«GUIãç解ããããªãããããªæãä»ã¾ã§ãã«ãæ¸ã®UIElementInspector.appãå©ç¨ãã¦ããã®ã ããä½ã¨ãéçºç°å¢(Xcodeãªã©)ã®ä¸ã«ãã¡ããã¨å ¥ã£ã¦ããï¼
- "/Developer/Applications/Utilities/Accessibility Tools/"
- Accessibility Inspector.app
- Accessibility Verifier.app
Accessibility Inspector.app
- ç®æãGUIã¾ã§ã®æ§é ãä¸ç®ã§ç¢ºèªãããã¨ãã§ããã
- ä¸è¨ã®UIElementInspector.appã¨ã»ã¼åãæ©è½ã
- ãã ããããã¹ãå称ã§ã¢ã¯ã»ã¹ã§ããªãå ´åã§ããããããå©ç¨ã§ããããã«ããã¹ãå称ã表示ãã¦ãã¾ãã®ã§ãã¡ãã£ã¨æ··ä¹±ããã
- UIElementInspector.appãªããããã¹ãå称ã§ã¢ã¯ã»ã¹ã§ããªãå ´åã¯ä½ã表示ããªããï¼ã¢ã¤ãã çªå·ãªãã¢ã¯ã»ã¹ã§ããç¶æ³ï¼
- ã ããä»ã§ããUIElementInspector.appã常ç¨ãã¦ããã
Accessibility Inspector.app | UIElementInspector.app |
---|---|
-
-
- 3è¡ç®ã®AXMenuBarItemã®éãã«æ³¨ç®ã
-
Accessibility Verifier.app
- ã¢ããªã±ã¼ã·ã§ã³ãæå®ãã¦ããã®ã¢ããªã±ã¼ã·ã§ã³å ¨ä½ã®GUIããªã¹ãæ§é ã¨ãã¦ä¿¯ç°ãããã¨ãã§ããã
- åãããããã¹ãå称ã§ã¢ã¯ã»ã¹ã§ããªãå ´åã§ããããããå©ç¨ã§ããããã«ããã¹ãå称ã表示ãã¦ãã¾ãã®ã§ãã¡ãã£ã¨æ··ä¹±ããã
ãã¼ã³ã¼ãã調ã¹ã
ã·ã§ã¼ãã«ããã§GUIã«ã¢ã¯ã»ã¹ããæãæå以å¤ã®ãã¼ã¯ãã¼ã³ã¼ãã§ã¢ã¯ã»ã¹ãããã¨ã«ãªãã
ä¾ãã°ãF1ï¼ãã¡ã³ã¯ã·ã§ã³ï¼ãã¼ã ã£ãããç¢å°ï¼ââââï¼ãã¼ã ã£ãããã§ãããã®ãã¼ã³ã¼ãã¯ï¼
key code 123 --âãã¼
ãããªæãä¸è©±ã«ãªã£ã¦ããã®ãã以ä¸ã®ã¢ããªã±ã¼ã·ã§ã³ã
Key Codes.app
ä½æ ãæ¬å®¶ã®ãµã¤ãã«ã¯ã¢ã¯ã»ã¹ã§ããªãç¶æ ï¼åé¤ããã¦ãã¾ã£ãï¼ï¼ãªã®ã§ãç¾å¨ã¯ãã©ã¼ããã®ã¿ãã¦ã³ãã¼ãã§ããã
ãã¼ã³ã¼ãä¸è¦§
- ãã®ãã¡ãã£ã¨ã使ããããªããããªãã¼ã³ã¼ããæ¾ã£ã¦ãããã
tell application "System Events"
--使ããããªããããªãã¼ã³ã¼ã
key code 53 --esc
key code 51 --delete
key code 48 --tab
key code 49 --space
key code 36 --return
key code 122 --F1
key code 120 --F2
key code 99 --F3
key code 118 --F4
key code 96 --F5
key code 97 --F6
key code 98 --F7
key code 100 --F8
key code 101 --F9
key code 109 --F10
key code 103 --F11
key code 111 --F12
key code 105 --F13
key code 107 --F14
key code 113 --F15
key code 123 --â
key code 124 --â
key code 125 --â
key code 126 --â
--tab, space, returnã¯keystrokeã§ãæä½å¯è½
keystroke tab
keystroke space
keystroke return
--ã¢ãã£ãã¡ã¤ã¤ãã¼ã®ä½¿ãæ¹
keystroke "v" using {command down, option down, shift down} keystroke "n" using {control down, shift down} end tell
ãã¦ã¹ã§ã¯ãªãã¯ãã
GUIã¹ã¯ãªããã£ã³ã°ã¨è¨ãã©ããæä½ã§ããªãGUIã¯å¿ ãããã
- ä¾ãã°ãFirefoxã®ã¦ã£ã³ãã¦å ã®GUIã¨ãã
- ã¡ãã¥ã¼ã¨ã¯ã¹ãã©ä»¥å¤ã®ã¡ãã¥ã¼ãã¼ã¢ã¤ã³ã³ãªã©ã
ã·ã§ã¼ãã«ããã§æä½ã§ãããªãã·ã§ã¼ãã«ããã®è¤åæã§å¯¾å¿ããã°è¯ããããããããã§ããªãå ´åã¯ãã¦ã¹ã§ã¯ãªãã¯ãããããªãã
cliclickã³ãã³ã
AppleScriptæ¨æºã§ã¯ãã¦ã¹ã®ã¯ãªãã¯æä½ã¯ãµãã¼ãããã¦ããªãããcliclickã³ãã³ããã¤ã³ã¹ãã¼ã«ããã°ãã¿ã¼ããã«ã®ã³ãã³ãã¨ãã¦ã¯ãªãã¯æä½ãå®è¡ã§ããã
do shell script "/usr/local/bin/cliclick 284 11"
- cliclickã³ãã³ãã®æ´»ç¨ä¾
以ä¸ããã¹ã¦ã®ã½ããã¦ã§ã¢ã«æ·±ã¼ãæè¬ã