Programmatically Toggle Colour Filters with AppleScript (osascript assistive access ERR: -25211)
Mac M1 2020. Monterey 12.2.1. ZSH.
I am trying to (title) from a terminal script.
I strongly prefer this method to others.
My error code running `osascript dd.scpt`
dd.scpt:654:718: execution error: System Events got an error: osascript is not allowed assistive access. (-25211)
- given AEServer and Terminal permissions in Security & Privacy > Accessibility to no avail.
- unable to find or add osascript permissions here.
- asked chatGPT multiple times & ways -- unhelpful/fake syntax suggestions for AppleScript
- looked for similar problems but can't find a solution relevant that works
This code gets to Accessibility > Display > Colour Filters and then throws the error. Changing to British spelling seems to make no difference:
tell application "System Preferences"
launch
reveal anchor "Seeing_ColorFilters" of pane "Accessibility"
end tell
tell application "System Events"
tell application process "System Preferences"
set frontmost to true
delay 1
tell window "Accessibility"
repeat until exists checkbox "Enable Color Filters" of tab group 1 of group 1
delay 0.01
end repeat
click first checkbox of tab group 1 of group 1
end tell
end tell
end tell
-- tell application "System Preferences" to if it is running then quit
MacBook Air 13″, macOS 12.2