2011-09-26 16 views
2

私は、AppleScriptを使用してシステム環境設定のロックを解除しようとしています。GUI Applescriptを使用したシステム環境設定のロック解除

は、私が「変更を加えるために、カギをクリックします」の部分をクリックして私のスクリプトを取得するために管理している、と私は、ユーザー名を入力するAppleScriptを取得しようとしていたが、私はエラー

error "System Events got an error: Can’t get window 1 of process \"SecurityAgent\". Invalid index." number -1719 from window 1 of process "SecurityAgent" 
を得続けます

ここに私のコードは、誰も私に手を差し伸べることができますか?

activate application "System Preferences" 
tell application "System Events" 
    set preferencesLocked to false 
    tell process "System Preferences" 
     delay 1 
     click menu item "Security & Privacy" of menu "View" of menu bar 1 
     delay 2.5 
     if title of button 4 of window 1 is "Click the lock to make changes." then 
      set preferencesLocked to true 
      click button "Click the lock to make changes." of window 1 
     end if 
    end tell 
    if preferencesLocked is true then 
     delay 2.5 
     activate application "SecurityAgent" 
     tell application "System Events" 
      tell process "SecurityAgent" 
       set value of text field 1 of scroll area 1 of group 1 of window 1 to "username" 
      end tell 
     end tell 
    end if 
end tell 

助けてください。ありがとうございました。

+0

ログインダイアログをスクリプトすることはできません。これはAppleが他のプログラムがあなたのコンピュータや何かにアクセスすることを望まないからだと私は思う。 – fireshadow52

+1

これは以前のバージョンのOSXでうまく動作していたと思いますか?これは私が最近遭遇した新しいものです: – user754905

+0

何を今実行していますか? – fireshadow52

答えて

0

認証ダイアログは、OS Xでは特別なものです。少なくともキーロガーによって読み取ることができない安全な方法で実装されています。

このような副作用として、また潜在的なセキュリティホールを導入するように思われるため、スクリプト作成が可能であれば、私は驚くでしょう。

あなたはたぶん運が悪いです、ごめんなさい。

1

これは、システムイベントの「キーストローク」コマンドを使用してパスワードを入力することで実行できます。ヨセミテバージョン(UI要素が移動しました):

set thePW to "MY_PASSWORD" 
set thePane to "Security & Privacy" 

activate application "System Preferences" 
delay 1 
tell application "System Events" 
    tell process "System Preferences" 
     click menu item thePane of menu "View" of menu bar 1 
     delay 3 
     if title of button 1 of window 1 is "Click the lock to make changes." then 
      click button 1 of window 1 
      delay 2 
      keystroke thePW 
      keystroke return 
     end if 
    end tell 
end tell 
関連する問題