2012-11-26 29 views
3

我有一個代碼來自動運行DiskWarrior的問題。問題是,當我打開應用程序時,SecurityAgent對話框彈出並詢問我的用戶名和密碼,並且我不知道如何「單擊」到安全代理窗口,以便我可以輸入用戶名和密碼。我知道如何編碼名稱/密碼,但我不知道如何「點擊」進入SercuirtyAgent窗口。我曾嘗試使用UI檢查器,但迄今爲止沒有運氣。是否有人知道如何編碼「點擊」SecurityAgent窗口如何點擊一個彈出對話窗口

任何/所有幫助和反饋,將不勝感激。

這裏是我到目前爲止,仍然在試圖搞清楚:

tell application "DiskWarrior" 
    open 
end tell 
delay 1 
tell application "System Events" 
    tell process "SecurityAgent" 
     click text field 1 
     delay 3 
     keystroke "a user name" 
       delay 3 
       keystroke tab 
       delay 3 
       keystroke "a password" 
       delay 3 
       keystroke return 
    end tell 
end tell 

回答

2

您可以set frontmost to trueactivate application "SecurityAgent"關注它。

tell application "System Events" to tell process "SecurityAgent" 
    set frontmost to true 
end 

您還可以使用UI腳本設置的密碼字段的值,然後單擊確定按鈕:

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

謝謝對於Lauri的迴應。 我嘗試了這兩個建議,但它似乎沒有做任何事情。 該代碼運行並打開diskwarrior,但只是在安全代理彈出時暫停。 赫雷什代碼我現在已經 告訴應用程序「DiskWarrior」 \t激活 端告訴 告訴應用程序「系統事件」告訴過程「SecurityAgent」窗口的1組的滾動區域1的文本字段2的 \t設定值1到「密碼」 \t點擊窗口1的第2組的按鈕2 end tell 它仍然不會「聚焦」或「切換到」彈出窗口 –

+0

根據您擁有的OSX版本,SecurityAgent對話框具有不同的UI。看到我的答案 –

0

對於優山美地,該SecurityAgent對話框是不同

tell application "DiskWarrior" 
    open 
end tell 
delay 1 
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