我在制作代码以自动运行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
答案 0 :(得分:2)
您可以使用set frontmost to true
或activate 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
答案 1 :(得分:0)
对于Yosemite,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