Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Yet another variant' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Yet another variant
Authored by: maeks84 on Dec 29, '09 08:21:46PM

Simplified determining the username and password. Just edit the script with whatever you need. Also, made it retry once if it failed to enter the password.

Begin script -
set thePassword to "password" --Set to "" if you wish to specify the password manually each time
set theUser to "username"
set theUser to do shell script "/usr/bin/id -u " & theUser
do shell script "/System/Library/CoreServices/Menu\\ Extras/User.menu/Contents/Resources/CGSession -switchToUserID " & theUser

if thePassword is not "" then --Password has been specified
repeat 2 times --Will only try twice before giving up
try
tell application "System Events"
tell process "SecurityAgent" to set value of text field 1 of group 1 of window 1 to thePassword
click button 2 of window 1 of application process "SecurityAgent"
end tell
exit repeat
on error
delay 1
end try
end repeat
end if



[ Reply to This | # ]