在Mac应用程序运行的AppleScript时,“不允许辅助访问”错误
问题描述:
我的代码是在Mac应用程序运行的AppleScript时,“不允许辅助访问”错误
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];
它打算自动改变图形,当我尝试它,我有错误
System Events got an error:“mactest”is not allowed for assistive access
我确定代码是正确的,它在AppleScript编辑器中运行良好,并且在删除“click \ n \”行时也可以正常运行。 我已经将我的应用以及AppleScript编辑器添加到安全&隐私中,但仍然无用。