How to check Full Keyboard Access status via AppleScript/Terminal?

Hello!

I’m relatively new to this forum and just wanted to say first how indispensable it has been this past year as I’ve been trying to teach myself AppleScript. Thanks to all of the community for their help! :cool:

I’m currently working on a project that uses the “Full Keyboard Access” feature in OS X (particularly for tabbing purposes). My question is: is there anyway to check if Full Keyboard Access has been enabled? The System Preferences dictionary only has a boolean for checking Assistive Devices ” perhaps there is something similar in AppleScript? Or maybe a “defaults read” command in Terminal?

In my efforts to find a solution, I stumbled upon the ~/Library/Preferences/com.apple.systempreferences.plist file and examined it. There is indeed a key titled “fullkeyboardaccess” but unfortunately whenever I toggle access on/off, the key does not change (and vice-versa)! I wonder which plist is actually mapped…

I’ve tried to do a good bit of searching before using everyone’s time but came up empty. Any ideas?

Thanks!

Model: MacBook Pro
AppleScript: 2.0
Browser: Safari 525.18
Operating System: Mac OS X (10.5)

Try this. I found it somewhere on macscripter so thanks to the original author… whoever you are. Sorry, I forget.

enable_GUI_scripting()

on enable_GUI_scripting()
	if (system attribute "sysv") < 4138 then display dialog "This script requires the installation of Mac OS X 10.3 or higher." buttons {"Cancel"} default button 1 with icon 2
	tell application "System Events" to if not UI elements enabled then
		tell me to display dialog "This script requires the built-in Graphic User Interface Scripting architecture of Mac OS X, which is currently disabled." & return & return & "Enable GUI Scripting now? (You may be asked to enter your password.)" buttons {"Cancel", "Enable"} default button 2 with icon 2
		set UI elements enabled to true
		if not UI elements enabled then error number -128
	end if
end enable_GUI_scripting

Hey thanks so much for the code and quick reply! This takes care of my GUI Scripting check perfectly. :slight_smile:

And about the other part: is there any way I could check to see if Full Keyboard Access is enabled in a similar way?

Thanks again for all your help.