虎(牛)龍未酉2.1

記録帳|+n年後のジブンが思い出せますように……

【記録】プロジェクタモードに切替(Automator、AppleScript、UI Element)

方針転換して、AppleScriptでUIを叩くことにしてみた。

遠回りな気もするけど……。

 

tell application "System Preferences"

activate

end tell

tell application "System Events"

if UI elements enabled then

tell process "System Preferences"

tell item 1 of pop up button 1 of tab group 1 of window 3 of application process "System Preferences" of application "System Events"

click

delay 0.2

click menu item "30" of menu 1

--set item_list to name of every UI element

--get every UI element

end tell

end tell

else

tell application "System Preferences"

activate

set current pane to pane "com.apple.preference.universalaccess"

display dialog "UI element scripting is not enabled."

end tell

end if

end tell

なんせここまで来た。

f:id:masatora_bd5:20181218000307p:plain

 

radio buttonを押すと、window 1→window 3に切り替わるというのがわかってなくて悩んだ。

 

pop up buttonの押し方も発見した。

ios - Selecting Pop Up Menu Buttons in AppleScript - Stack Overflow

 

UI Elementを探す(手作業だけど)方法も発見した。

AppleScriptでUI Elementsをリストで取得して使う方法 - Qiita

[AppleScript] UI Elementsをリストとして取得

AppleScriptでモニタの明るさ… - Apple コミュニティ