2011-09-26 5 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

로그인 대화 상자를 스크립팅 할 수 없습니다. 나는 애플이 다른 프로그램이 당신의 컴퓨터 나 다른 것들에 접근하는 것을 원하지 않기 때문이라고 생각한다. – 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