【问题标题】:AppleScript: Error thrown when trying to read UI elements enabledAppleScript:尝试读取启用的 UI 元素时引发错误
【发布时间】:2014-11-01 16:19:57
【问题描述】:

如果我从终端运行以下命令

osascript -e 'tell application "System Events" to get UI elements enabled'

我按预期得到“真”或“假”

但是如果我要创建一个包含以下内容的文件;

#!/usr/bin/osascript

on supportsAssistiveDevices()
  tell application "System Events"
    set isEnabled to UI elements enabled
    return isEnabled as boolean
  end tell
end supportsAssistiveDevices

log supportsAssistiveDevices()

通过./myfile运行它,我得到以下错误;

./hasguiscript:87:106: execution error: An error of type -10810 has occurred. (-10810)

谁能帮忙解释一下为什么会这样?

谢谢。

【问题讨论】:

    标签: macos applescript ui-automation osx-yosemite


    【解决方案1】:

    这在 10.9 之前就没有用了。您不启用 ui 元素作为一个设置。您必须启用请求访问 ui 元素的每个单独的应用程序。这是一项“安全”功能,没有自动方式来启用应用程序。所以你的代码已经一年多没有工作了。

    system preferences->security & privacy->privacy->accessibility
    

    【讨论】:

      猜你喜欢
      • 2022-12-08
      • 1970-01-01
      • 2011-08-24
      • 2019-08-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-20
      • 1970-01-01
      相关资源
      最近更新 更多