首页 > 解决方案 > 应用程序在启动时被移除辅助访问

问题描述

我对 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)

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

标签: macosapplescript

解决方案


转到系统偏好设置-> 安全和隐私->可访问性

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

现在,存在 2 种情况可以进一步推进:

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

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


推荐阅读