由 AppleScript 控制的自动化 VoiceOver

Automate VoiceOver being controlled by AppleScript

我正在尝试找到一种方法来自动检查 VoiceOver Utility.app 上的 Allow VoiceOver to be controlled with AppleScript 选项,以便 AppleScript 可以控制 VoiceOver。专门用于 GitHub 操作 macos 工作流程。

据我所知,是否启用此功能取决于是否存在 /private/var/db/Accessibility/.VoiceOverAppleScriptEnabled 文件(包含单个字符 a - 通过深入研究 VoiceOver Utility / ScreenReaderCore.framework),但是这个目录有 SIP,所以写文件是不行的(禁用 SIP 不是一个选项)。

它似乎还试图导入 .voprefs 文件并将 SCREnableAppleScript 键设置为 true 被简单地忽略。

尝试UI脚本点击复选框似乎只是在macos-11或macos-10.15 envs的GitHub操作中什么都不做,最终状态的屏幕截图看起来什么也没有根本没有发生(复选框保持未选中状态,没有 SecurityAgent 弹出窗口的迹象 window 等)。为了完整起见,这是我试过的脚本:

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

有什么想法吗?!

VoiceOver 的 AppleScript 控件现在可用于 GitHub 与维护者协作后的操作。现在默认勾选相关复选框。

问题:https://github.com/actions/virtual-environments/issues/4770

PR: