3

I am having a problem with making a code to run DiskWarrior Automatically. The Problem is when i open the application, a SecurityAgent Dialog Pops up and asks for my username and password, and i do not know how to "click" into the Security Agent window so i can type in the username and password. I know how to code the name/password but i don't know how to "click" into the SercuirtyAgent window. I have tried using the UI inspector but thus far have had no luck. Does any one know how to code "clicking" the SecurityAgent window

Any/all help and feedback would be appreciated.

Here is what i have so far, still trying to figure it out:

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
adayzdone
  • 11,120
  • 2
  • 20
  • 37
Alex Joy
  • 51
  • 1
  • 3

2 Answers2

2

You can focus it with set frontmost to true or activate application "SecurityAgent".

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

You can also use UI scripting to set the value of the password field and click the OK button:

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
Lri
  • 26,768
  • 8
  • 84
  • 82
  • Thanks for the response Lauri. I tried out those 2 suggestions but it didn't seem to do anything. The code runs and opens diskwarrior but then just pauses when the security agent pops up. Heres the code i have now tell application "DiskWarrior" activate end tell 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 It still wont "focus" or "switch into" the popup window – Alex Joy Nov 27 '12 at 15:11
  • Depending on what OSX version you have, the SecurityAgent dialog box has a different UI. See my answer – nvrtd frst May 15 '15 at 05:58
0

For Yosemite, the SecurityAgent dialog box is different

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
nvrtd frst
  • 6,272
  • 4
  • 28
  • 34