Hey all,
I’m writing a script for Disk Warrior to replace the directory automatically when I’m not there. This is the problem:
when disk warrior starts up it asks for an admin username and password. My question is how do I get my script to fill in the password and hit ok to continue starting up the application? I was thinking I could do a tell to open the application and put in the password for me. That way the rest of my scripting will just run without problems.
Model: MacBook Core Duo 2.0 ghz Black
AppleScript: 1.10.7
Browser: Safari 419.3
Operating System: Mac OS X (10.4)
launch application "DiskWarrior"
authenticate_changes()
-- go on
to authenticate_changes()
tell application "System Events"
repeat until (exists window "Authenticate" of process "SecurityAgent")
delay 0.5
end repeat
tell window "Authenticate" of process "SecurityAgent"
tell group 1
set value of text field 1 to "Administrator"
set value of text field 2 to "myfakepassword"
end tell
click button "OK" of group 2
end tell
end tell
end authenticate_changes
once again, StefanK, you have opened my eyes. One more question:
now, my problem is that when diskwarrior comes to the screen where it tells you what problems it found. It asks if you want to replace the directory or cancel. I need it to select rebuild everytime. Any suggestions?
I am trying to modify this script so it enters the username and password for an unlocked System Preference window, i.e. “System Preferences requires that you type your password.”
I modified the script slightly thinking that it might work but with no success. Can anybody help me out?
launch application "System Preferences"
authenticate_changes()
-- go on
to authenticate_changes()
tell application "System Events"
repeat until (exists window "Authenticate" of process "SecurityAgent")
delay 0.5
end repeat
tell window "Authenticate" of process "SecurityAgent"
tell group 1
set value of text field 1 to "Administrator"
set value of text field 2 to "myfakepassword"
end tell
--click button "OK" of group 2
end tell
end tell
end authenticate_changes
No, it isn’t. The authenticate window of System Preferences has no name, therefore the hint to use window 1
this works on my machine (10.5.8)
launch application "System Preferences"
tell application "System Events"
tell process "System Preferences"
tell button 4 of window 1
if its name is "Click the lock to make changes." then
click
my authenticate_changes()
end if
end tell
end tell
end tell
-- go on
to authenticate_changes()
tell application "System Events"
repeat until (exists window 1 of process "SecurityAgent")
delay 0.5
end repeat
tell window 1 of process "SecurityAgent"
tell scroll area 1 of group 1
set value of text field 1 to "Administrator"
set value of text field 2 to "myfakepassword"
end tell
click button "OK" of group 2
end tell
end tell
end authenticate_changes