OS X Yosemite and osascript: Enabling Access to Assistive Devices

OS X Yosemite and osascript: Enabling Access to Assistive Devices

I love automating things, so I also wrote a command line utility that you can use to add items into the accessibility database (located at /Library/Application Support/com.apple.TCC/tcc.db ).

https://github.com/jacobsalmela/tccutil/releases

An example of how to use this, would be to allow TextExpander 4 access to assistive devices:

sudo tccutil.py --insert com.smileonmymac.textexpander 
sudo tccutil.py --insert com.smileonmymac.textexpander.helper

The solution above was not needed prior to Mavericks and Yosemite because a single command would enable all apps access to assistive devices:

sudo touch /private/var/db/.AccessibilityAPIEnabled

You can also always drag-and-drop apps into the System Preference pane, but sometimes scripting things is a lot easier.

The latest iterations of the OS, however, have moved these settings to a per-app basis.  Each app must be allowed access to assistive devices.  It is easy enough to drag and drop an .app into the Security and Privacy section of System Preferences, but you cannot drop command line tools in, which is another reason I created tccutil.py.

You can always use sqlite3  to add items into the accessibility database, which is basically what the command line tool does, but using the tccutil.py just makes things a little easier.  It also helps with OS X administration as it can be used in scripts to deploy settings system-wide.

Applescript (or osascript  at the command line) can be used to automate GUI tasks such as clicking buttons or entering keystrokes.  I posted previously how to script a GUI login in Mavericks.  This trick still works great in Yosemite.  Once enabled, a simple Python script handles the rest.