Pick of the Week - Nov 10 [Show all picks]
Path Finder 5 - A feature-laden Finder replacement
Submit Hint Search The Forums LinksStatsPollsFAQHeadlinesRSS
12,000 hints and counting!

Enable and disable Assistive Devices via Terminal System
The feature called 'Enable access for assistive devices' is found in the Universal Access preference pane. It needs to be enabled in order for any GUI AppleScripts to run. I was trying to enable it from the Terminal, to insure that it was always enabled when needed. I struggled with this for a long time, and then finally found a simple solution.

To turn it on, type this in Terminal:
sudo touch /private/var/db/.AccessibilityAPIEnabled
To then disable it, type this:
sudo rm /private/var/db/.AccessibilityAPIEnabled
Thats it. If you wanted to AppleScript it, you could do something like this:
do shell script ¬
  "touch /private/var/db/.AccessibilityAPIEnabled" password "pwd" ¬
  with administrator privileges
[robg adds: Somewhat obviously, replace pwd with your admin user's password. Also, change touch to rm for the opposite version of the AppleScript.]
    •    
  • Currently 5.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[10,512 views]  

Enable and disable Assistive Devices via Terminal | 6 comments | Create New Account
Click here to return to the 'Enable and disable Assistive Devices via Terminal' hint
The following comments are owned by whomever posted them. This site is not responsible for what they say.
Enable and disable Assistive Devices via Terminal
Authored by: jay1 on Thu, Feb 9 2006 at 8:39AM PST
Excellent. I was looking at this problem, and I'm glad you got it sussed. I do however remove the part that says: [b]password pwd [/b] as I'm sure the script will prompt you for an admin password. I'm looking at this from a security point of view. Regards, Jay

---
-J-

[ Reply to This | # ]

Enable and disable Assistive Devices via Terminal
Authored by: gilburns on Thu, Feb 9 2006 at 9:43AM PST
If you just want to just applescript turning on and off GUI scripting, then you can do something like this:

tell application "System Events"
set UI elements enabled to true
end tell

The user will get prompted to enter their credentials. No need to use the do shell script.


[ Reply to This | # ]
Contents of file?
Authored by: ClassicUser on Mon, May 1 2006 at 5:24PM PDT
On my 10.4.6 system, this file actually appears to contain a single character - in my case, the letter "a".

So, to be safe, it appears it would be better to:

sudo echo "a" > /private/var/db/.AccessibilityAPIEnabled
...instead.

[ Reply to This | # ]
Contents of file?
Authored by: ClassicUser on Mon, May 1 2006 at 5:28PM PDT
Argh - submitted too soon...

Almost correct: The file should NOT contain the trailing newline. So, that means it should be:

sudo echo -n "a" > /private/var/db/.AccessibilityAPIEnabled
(with the extra "-n" switch passed to echo)

Sorry about that...

[ Reply to This | # ]

Contents of file?
Authored by: Adam van Gaalen on Tue, Sep 15 2009 at 4:28AM PDT
I figured out it would even be better to change that into:

sudo echo -n "a" > /private/var/db/.AccessibilityAPIEnabled
sudo chmod 444 /private/var/db/.AccessibilityAPIEnabled

Not using the -n would leave an 'a' followed by a 'newline' inside the file instead of just the 'a'

[ Reply to This | # ]
Enable and disable Assistive Devices via Terminal
Authored by: general_ludd on Fri, Jul 13 2007 at 8:25PM PDT
It is useful to point out that System Preferences should not be open during this procedure. I discovered this while debugging a script that used the aforementioned code while I had the Accessibility prefpane open.


[ Reply to This | # ]