问题描述
限时送ChatGPT账号..如果我从终端运行以下内容
If I run the following from Terminal
osascript -e 'tell application "System Events" to get UI elements enabled'
我按预期得到真"或假"
I get "true" or "false" as expected
但是如果我要创建一个包含以下内容的文件;
But if I were to create a file with the following contents;
#!/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
运行它,我得到以下错误;
and run it via ./myfile
, I get the following error;
./hasguiscript:87:106: execution error: An error of type -10810 has occurred. (-10810)
谁能帮忙解释一下为什么会这样?
Can anyone help shed some light on why that might be?
谢谢.
推荐答案
这在 10.9 之前就不起作用了.您不会将 ui 元素作为一种设置启用.您必须启用每个请求访问 ui 元素的应用程序.这是一项安全"功能,没有启用应用程序的自动化方法.所以你的代码已经一年多了.
This hasn't worked since before 10.9. You do not enable ui elements as one setting. You must enable each individual application that requests access to ui elements. It's a "security" feature and there's no automated way to enable an application. So your code hasn't worked for over a year now.
system preferences->security & privacy->privacy->accessibility
这篇关于AppleScript:尝试读取启用的 UI 元素时引发错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论