如果我将我的Applescript交给另一个人,他们必须手动允许Applescript控制他们的计算机,方法是进入系统首选项,单击安全和隐私,然后单击隐私,然后单击辅助功能,最后添加Applescript。有没有什么办法可以让Applescript添加它自己的内容,这样他们就不用这么做了?有没有其他的解决方案?因为如果不这样做,Applescript就无法单击内容。
如果没有添加applescript以使其可以控制,我会得到错误,“脚本编辑器不允许辅助访问”。
发布于 2015-04-21 12:34:40
我相信您正在尝试为设备启用辅助访问。例如,GUI脚本需要启用此功能。您不能直接启用它,但您可以将用户指向他们需要去的地方。下面将找出是否启用了辅助访问,并调出选项所在的系统首选项窗格。
tell application "System Events"
set UI_enabled to UI elements enabled
end tell
if UI_enabled is false then
tell application "System Preferences"
activate
set current pane to pane id "com.apple.preference.universalaccess"
display dialog "This script utilizes the built-in Graphic User Interface Scripting architecture of Mac OS x which is currently disabled." & return & return & "You can activate GUI Scripting by selecting the checkbox \"Enable access for assistive devices\" in the Universal Access preference pane." with icon 1 buttons {"Cancel"} default button 1
end tell
end if这应该足以让你的用户明白这一点。
发布于 2018-01-26 03:00:06
从理论上讲,您可以通过命令行完成此操作:
https://raymii.org/s/snippets/OS-X-Enable-Access-for-assistive-devices-via-command-line.html
例如,在Lion和Mountain Lion中,它是这样的简单:
touch /private/var/db/.AccessibilityAPIEnabledhttps://stackoverflow.com/questions/26591560
复制相似问题