I'm trying to find a way to automate the checking of the Allow VoiceOver to be controlled with AppleScript
option on VoiceOver Utility.app
so that VoiceOver can be controlled by AppleScript. Specifically for use in GitHub actions macos workflows.
From what I can tell, whether this is enabled or not is driven by the presence of a /private/var/db/Accessibility/.VoiceOverAppleScriptEnabled
file (containing the single character a
- as determined by digging into VoiceOver Utility
/ ScreenReaderCore.framework
), but this directory has SIP so writing the file is a no-go (disabling SIP not an option).
It also appears trying to import a .voprefs
file with the SCREnableAppleScript
key set to true is simply ignored.
Attempts to UI script the clicking of the checkbox appears to just being doing nothing in GitHub actions for macos-11 or macos-10.15 envs, and screenshots of the final state look like nothing has happened at all (checkbox remains unchecked, no sign of SecurityAgent popup window etc.). For completeness here's the script I've tried:
delay 2
log "Starting AppleScript..."
do shell script "mkdir -p ./screenshots"
do shell script "screencapture ./screenshots/starting.png"
log "Activating VoiceOver Utility..."
tell application "VoiceOver Utility" to activate
delay 1
tell application "System Events"
repeat while not (exists window 1 of application process "VoiceOver Utility")
delay 0.1
end repeat
do shell script "screencapture ./screenshots/activated.png"
log "Ticking checkbox..."
tell application process "VoiceOver Utility"
repeat until (exists checkbox 2 of splitter group 1 of window 1)
delay 0.1
end repeat
click checkbox 2 of splitter group 1 of window 1
end tell
delay 2
do shell script "screencapture ./screenshots/checkbox.png"
end tell
log "Quiting VoiceOver Utility..."
tell application "VoiceOver Utility"
quit
end tell
Any ideas?!
AppleScript control of VoiceOver is now available out of the box for GitHub actions following some collaboration with the maintainers. The checkbox in question is now ticked by default.
Issue: https://github.com/actions/virtual-environments/issues/4770
PRs: