Reputation: 51
My code is
NSAppleScript* scriptObject = [[NSAppleScript alloc] initWithSource:
@"\
tell application \"System Preferences\"\n\
set current pane to pane id \"com.apple.preference.energysaver\"\n\
end tell\n\
tell application \"System Events\"\n\
tell process \"System Preferences\"\n\
tell window 1\n\
tell group 1 -- automatic graphics switching\n\
tell checkbox 1 -- automatic graphics switching\n\
click\n\
end tell\n\
end tell\n\
end tell\n\
end tell\n\
end tell"];
returnDescriptor = [scriptObject executeAndReturnError: &errorDict];
it's intend to change Graphics automatically,when I try it,I have that error
System Events got an error:“mactest”is not allowed for assistive access
I'm sure the code is correct,it works well in AppleScript Editor,and also ran without error if delete "click\n\" line. And I'm already add my app as well as AppleScript Editor into Security & Privacy,but still useless.
Upvotes: 2
Views: 1266
Reputation: 201
I believe I've run into this issue as well. I wanted to make a small AppleScript to focus and maximize StepMania. I exported it as an App so I could add it to the login items. Adding in the maximizing functionality worked after I gave AppleScript Editor accessibility permission.
However, after exporting it as an application, it was now not running through AppleScript Editor and did not have the required accessibility permission.
You need to give your App accessibility permissions.
Some dialog like this might lead you to dragging your app to the list.
Upvotes: 1