If I run the following from Terminal
osascript -e 'tell application "System Events" to get UI elements enabled'
I get "true" or "false" as expected
But if I were to create a file with the following contents;
#!/usr/bin/osascript
on supportsAssistiveDevices()
tell application "System Events"
set isEnabled to UI elements enabled
return isEnabled as boolean
end tell
end supportsAssistiveDevices
log supportsAssistiveDevices()
and run it via ./myfile
, I get the following error;
./hasguiscript:87:106: execution error: An error of type -10810 has occurred. (-10810)
Can anyone help shed some light on why that might be?
Thanks.
This hasn't worked since before 10.9. You do not enable ui elements as one setting. You must enable each individual application that requests access to ui elements. It's a "security" feature and there's no automated way to enable an application. So your code hasn't worked for over a year now.