Enabling GUI scripting via AppleScript

So I have a launch-daemon that needs to utilize GUI scripting. I need to be able to enable it through AppleScript (or really any scriptable, automated means). I am trying to do this:


tell application "System Events" to if not UI elements enabled then

set UI elements enabled to true

return UI elements enabled

end if


but it doesn't seem to do anything. The return query is just to check that it worked, but it never does. I have tried saving the script and running it as administrator (sudo osascript myScript.scpt) but it still doesn't work. I never get prompted for admin credentials. This occurs when logged in as administrator or non-admin user. Any ideas?

Posted on Nov 12, 2012 5:25 PM

Reply
19 replies

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Enabling GUI scripting via AppleScript

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.