私のコードは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 Editorと同様にSecurity & Privacyに自分のアプリを追加していますが、まだ役に立たないです。