Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,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 3.33 / 5
  You rated: 5 / 5 (9 votes cast)
 
[47,066 views]  

Enable and disable Assistive Devices via Terminal | 8 comments | Create New Account
Click here to return to the 'Enable and disable Assistive Devices via Terminal' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Enable and disable Assistive Devices via Terminal
Authored by: jay1 on Feb 09, '06 08:39:41AM
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 Feb 09, '06 09:43:48AM
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 May 01, '06 05:24:22PM
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 May 01, '06 05:28:04PM
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 Sep 15, '09 04:28:55AM

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 Jul 13, '07 08:25:07PM

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 | # ]
Enable and disable Assistive Devices via Terminal
Authored by: eddit on May 24, '10 06:54:40AM

In Snow leopard I find that this does not work. It creates the hidden file, places the "a" within, and in system preferences the "enable access for..." is checked, but my applescripts still say "access for assistive devices is disabled". Only once I manually check the checkbox do the scripts work. This leads me to believe that something else, other than the .AccessibilityAPIEnabled file is happening under Snow Leopard.

My whole goal is to have a window/app management script that launches and places all of my startup apps/windows for dual monitors. I despise the automated mouse movement that comes with "access for assistive devices" but I need this to move and resize the windows so in a single applescript i want to:
1. turn the access on
2. move and place the windows
3. turn the access off



[ Reply to This | # ]
Enable and disable Assistive Devices via Terminal
Authored by: elvisizer on Sep 28, '11 11:09:37AM

works in Lion!



[ Reply to This | # ]