2017-03-18 7 views
2

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

答えて

0

私もこの問題にぶつかったと思います。私はStepManiaを集中し最大化するために小さなAppleScriptを作りたがっていました。私はそれをアプリケーションとしてエクスポートしたので、ログイン項目に追加することができました。私がAppleScript Editorのアクセシビリティアクセス許可を与えた後、最大限の機能を追加することができました。

System Preferences -> Security & Privacy -> Privacy -> Accessibility -> AppleScript Editor

ただし、アプリケーションとしてそれをエクスポートした後、それは今のAppleScriptエディタを使用して実行されていなかったし、必要なアクセス権限を持っていませんでした。

AppleScript app is not allowed assistive access

あなたはアプリのアクセシビリティ権限を与える必要があります。

AppleScript app would like to control this computer using accessibility features

このようないくつかのダイアログがリストにアプリをドラッグするあなたを導く可能性があります。

関連する問題