应用程序在启动时获取辅助访问权限

App gets assistive access removed when launched

我是 AppleScript 的新手,这是我的第一个脚本。我正在尝试通过一个应用程序启动 GeoGuessr,并将用户代理更改为 Google Chrome(因为默认的确实有问题)

这是我的代码

tell application "Safari" to activate
tell application "Safari"
    tell front window
        set current tab to (make new tab with properties {URL:"https://geoguessr.com"})
    end tell
end tell
tell application "System Events"
    tell process "Safari"
        click menu item "Google Chrome — MacOS" of menu "User Agent" of menu item "User Agent" of menu "Develop" of menu bar item "Develop" of menu bar 1
    end tell
end tell

当我通过脚本编辑器启动它时,它起作用并将用户代理更改为 chrome。但是当我 运行 它通过应用程序本身时,它给了我这个错误。

System Events got an error: GeoGuessr is not allowed assistive access. (-1719)

每次我去检查设置中的权限时,我的应用程序旁边的小框不再被勾选。为什么要这样做?

转到系统偏好设置 --> 安全和隐私 --> 辅助功能

您的应用程序应该在 允许控制计算机的应用程序列表中

现在,有2个案例需要进一步推进:

a) 您应用的复选框 未选中 。 在这种情况下,只需检查它。

b) 您应用的复选框已 CHECKED(但并不像您所说的那样工作)。 在这种情况下,使用减号按钮从列表中删除您的应用程序, 重新启动您的应用,再次执行步骤 a)。