Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何通过Applescript授予Applescript权限?_Applescript_System Preferences - Fatal编程技术网

如何通过Applescript授予Applescript权限?

如何通过Applescript授予Applescript权限?,applescript,system-preferences,Applescript,System Preferences,如果我将Applescript交给其他人,他们必须手动允许Applescript控制他们的计算机,方法是进入系统首选项,单击安全和隐私,然后单击隐私,然后单击可访问性,最后添加Applescript。我是否可以让Applescript添加它自己,这样他们就不必这样做?还有别的解决办法吗?因为如果他们不这样做,Applescript就不能点击东西 如果没有添加applescript使其具有控制权,我会得到错误,“脚本编辑器不允许辅助访问。”我相信您正在尝试为设备启用辅助访问。例如,GUI脚本要求启

如果我将Applescript交给其他人,他们必须手动允许Applescript控制他们的计算机,方法是进入系统首选项,单击安全和隐私,然后单击隐私,然后单击可访问性,最后添加Applescript。我是否可以让Applescript添加它自己,这样他们就不必这样做?还有别的解决办法吗?因为如果他们不这样做,Applescript就不能点击东西


如果没有添加applescript使其具有控制权,我会得到错误,“脚本编辑器不允许辅助访问。”

我相信您正在尝试为设备启用辅助访问。例如,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

这应该足以让您的用户得到提示。

理论上,您可以通过命令行执行此操作:

例如,在《狮子与山狮》中,它是这样一个简单的例子:

touch /private/var/db/.AccessibilityAPIEnabled

可能不会-如果受限制的代码可以在没有用户干预的情况下为自己提供完全权限,这将是一个相当大的安全漏洞。我有没有办法让他们输入密码,然后它会为他们更改密码?请检查以下内容: