2
votes

If I give my Applescript to another person, they would have to manually allow Applescript control of their computer by going into System Preferences, clicking Security & Privacy, then clicking Privacy and then Accessibility, then finally add Applescript. Is there anyway I can make Applescript add its self so they don't have to? Is there another solution? Because without them doing this, Applescript can't click things.

Without applescript added so it can have control, I get the error, "Script Editor is not allowed assistive access."

2
Probably not - it would be a rather large security hole if restricted code could give itself full privileges without user intervention.nobody
Is there a way I could have them enter their password then it would change it for them?James

2 Answers

2
votes

I believe that your are trying to enable assistive access for devices. For instance, GUI scripting requires this to be enabled. You can't enable it directly, but you can point the user to the place they need to go. The following finds out if assistive access is enabled and brings up the System Preference pane where the option is.

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

That should be enough for your users to get the hint.

0
votes

You can theoretically do it via the command line:

https://raymii.org/s/snippets/OS-X-Enable-Access-for-assistive-devices-via-command-line.html

For example, in Lion and Mountain Lion it's a simple as this:

touch /private/var/db/.AccessibilityAPIEnabled