In Mavericks the code below fails:
tell application "System Events"
set testApp to "TextEdit.app"
if not (application process testApp exists) then tell application process testApp to activate
log (UI elements enabled) as boolean -- Events logged: (*false*)
try
set (UI elements enabled) to not (UI elements enabled)
on error e
return e
end try
end tell
-- result returned: "System Events got an error: Can't set UI elements enabled of application to true."
Does anybody know how to modify the code below so that it adds the current application to the allowed apps list (checked on) of Security & Privacy prefPane?
It will surely have to be done by entering an admin password but that’s ok for my purpose.
Thanks.
-- for the login items this code works
try
tell application "System Events"
set myPath to (path to current application)
set myName to (name of current application)
log "myName is in (name of every login item) returns: " & (myName is in (name of every login item)) as text -- (*myName is in (name of every login item) returns: false*)
if myName is not in (name of every login item) then
make new login item at end of login items with properties {name:myName, kind:"APPLICATION", path:myPath, hidden:true}
end if
log "myName is in (name of every login item) returns: " & (myName is in (name of every login item)) as text -- (*myName is in (name of every login item) returns: true*)
if (myName is in (name of every login item)) then
display dialog "Success" with icon 1 buttons {"OK"} default button 1
end if
end tell
on error myErr
log myErr
display dialog "Failed to add to login items, you'll have to do it manually." with icon 1 buttons {"OK"} default button 1
end try