2013-05-30 84 views
4

我是新來的applescript,目前卡在訪問提示窗口詢問我的密碼。如何使用applescript輸入提示窗口的密碼

我正在爲我的日常使用應用程序創建一個啓動器,並且我想自動啓動啓動過程。

現在,我只推出兩個應用程序,VirtualHostX和MAMP。稍後我可能會添加一些。

這是我迄今所做的:

tell application "VirtualHostX" to activate 
tell application "MAMP" to activate 

tell application "System Events" 
    tell process "VirtualHostX" 
     tell menu bar 1 
      tell menu bar item "Web Server" 
       tell menu 1 
        click menu item "Start" 
       end tell 
      end tell 
     end tell 
    end tell 
end tell 

發射時,將成功啓動了兩個應用,但虛擬主機會問我要我的密碼進行授權。我想集成在流程或代碼中輸入我的密碼。我已經嘗試谷歌的答案,但沒有找到它的解決方案。

我似乎無法定位該窗口並輸入我的密碼。 enter image description here

讓我知道我錯過了什麼。

謝謝。

回答

6

密碼的對話框是由SecurityAgent所示:

tell application "System Events" to tell process "SecurityAgent" 
    set value of text field 2 of scroll area 1 of group 1 of window 1 to "password" 
    click button 2 of group 2 of window 1 
end tell 
+0

工程就像一個魅力,勞裏。 – Pennf0lio

+0

我認爲約塞米蒂發生了一件事情,使得這種情況不再起作用。有什麼建議麼? –

0

對於約塞米蒂,所述SecurityAgent對話框是不同的。這將工作:

tell application "System Events" 
    tell process "SecurityAgent" 
     set value of text field 2 of window 1 to "yourPassword" 
     click button 2 of window 1 
    end tell 
end tell