2012-11-26 27 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