【问题标题】:“is not allowed for assistive access” error when running AppleScript in Mac app在 Mac 应用程序中运行 AppleScript 时出现“不允许辅助访问”错误
【发布时间】:2017-08-09 21:20:58
【问题描述】:

我的代码是

NSAppleScript* scriptObject = [[NSAppleScript alloc] initWithSource:
                               @"\
                               tell application \"System Preferences\"\n\
                               set current pane to pane id \"com.apple.preference.energysaver\"\n\
                               end tell\n\
                               tell application \"System Events\"\n\
                               tell process \"System Preferences\"\n\
                               tell window 1\n\
                               tell group 1 -- automatic graphics switching\n\
                               tell checkbox 1 -- automatic graphics switching\n\
                               click\n\
                               end tell\n\
                               end tell\n\
                               end tell\n\
                               end tell\n\
                               end tell"];

returnDescriptor = [scriptObject executeAndReturnError: &errorDict];

它打算自动更改图形,当我尝试时,我有这个错误

系统事件出错:“mactest”不允许辅助访问

我确定代码是正确的,它在 AppleScript 编辑器中运行良好,如果删除 "click\n\" 行,也可以正常运行。 而且我已经将我的应用程序和 AppleScript 编辑器添加到安全和隐私中,但仍然没用。

【问题讨论】:

    标签: macos applescript authorization nsapplescript


    【解决方案1】:

    我相信我也遇到过这个问题。我想制作一个小的 AppleScript 来聚焦和最大化 StepMania。我将其导出为应用程序,以便将其添加到登录项中。在我授予 AppleScript Editor 可访问性权限后,添加最大化功能起作用了。

    但是,在将其导出为应用程序后,它现在无法通过 AppleScript 编辑器运行,并且没有所需的可访问权限。

    您需要授予您的应用访问权限。

    这样的一些对话框可能会引导您将应用拖到列表中。

    【讨论】:

      猜你喜欢
      • 2015-09-10
      • 2014-02-16
      • 1970-01-01
      • 2016-04-09
      • 1970-01-01
      • 1970-01-01
      • 2017-05-06
      • 2015-02-21
      • 1970-01-01
      相关资源
      最近更新 更多