VenturaのAppleScriptにおけるGUIスクリプティング(バグ)
VenturaのAppleScriptにおいて、ControlCenterをGUIスクリプティングで操作したいが各要素の「nameプロパティ」が全く実装されていないためそれができない。
(Montereyで動作していたスクリプトがVenturaで動作しなくなった。
なお、Musicなど他のアプリケーションではこの問題は発生していない。
一応、フィードバックはしてありますが、何か他に回避手段があればご教示ください。
(検証用スクリプトと実行結果)
set menuDelay to 1
set menuName to 5 --"サウンド"
set devList to {}
tell application "System Events"
tell application process "ControlCenter"
tell menu bar 1's menu bar item menuName
perform action "AXPress"
(*
try
key down {option}
perform action "AXPress"
key up {option}
on error
key up {option}
end try
*)
end tell
delay menuDelay
tell window 1
set ret to every UI element
tell group 1's scroll area 1
set btns to every checkbox
set devCurrent to ""
repeat with btn in btns
btn's name --properties
(*
set devName to btn's name
set devName to my devText(devName, ",")'s item 1
if btn's value is 1 then set devName to ";" & devName
set devList's end to devName
*)
end repeat
end tell
end tell
end tell
delay menuDelay
key code 53
end tell
if (count devList) is 0 then
set the clipboard to "Nothing"
return
else
repeat with n from 1 to (count devList)
if n is 1 then
set devStr to devList's item 1
else
set devStr to devStr & "," & devList's item n
end if
end repeat
set the clipboard to devStr
return
end if
on devText(theText, aDelimiter)
set tmp to AppleScript's text item delimiters
set AppleScript's text item delimiters to aDelimiter
set theList to theText's every text item
set AppleScript's text item delimiters to tmp
return theList
end devText
tell application "System Events"
perform action "AXPress" of menu bar item 5 of menu bar 1 of application process "ControlCenter"
--> action "AXPress" of menu bar item 5 of menu bar 1 of application process "ControlCenter"
get every UI element of window 1 of application process "ControlCenter"
--> {group 1 of window "コントロールセンター" of application process "ControlCenter"}
get every checkbox of scroll area 1 of group 1 of window 1 of application process "ControlCenter"
--> {checkbox 1 of scroll area 1 of group 1 of window "コントロールセンター" of application process "ControlCenter", checkbox 2 of scroll area 1 of group 1 of window "コントロールセンター" of application process "ControlCenter", checkbox 3 of scroll area 1 of group 1 of window "コントロールセンター" of application process "ControlCenter", checkbox 4 of scroll area 1 of group 1 of window "コントロールセンター" of application process "ControlCenter", checkbox 5 of scroll area 1 of group 1 of window "コントロールセンター" of application process "ControlCenter"}
get name of checkbox 1 of scroll area 1 of group 1 of window "コントロールセンター" of application process "ControlCenter"
--> missing value
get name of checkbox 2 of scroll area 1 of group 1 of window "コントロールセンター" of application process "ControlCenter"
--> missing value
get name of checkbox 3 of scroll area 1 of group 1 of window "コントロールセンター" of application process "ControlCenter"
--> missing value
get name of checkbox 4 of scroll area 1 of group 1 of window "コントロールセンター" of application process "ControlCenter"
--> missing value
get name of checkbox 5 of scroll area 1 of group 1 of window "コントロールセンター" of application process "ControlCenter"
--> missing value
key code 53
end tell
tell application "Script Editor"
set the clipboard to "Nothing"
end tell
(MontereyとVenturaのMenu bar itemのプロパティ設定値の相違)
MacBook Pro 16″