PDA

View Full Version : AppleScript password




fivetoadsloth
Dec 29, 2006, 02:20 PM
Is there a way in apple scipt to open the dialogue box asking for an admin password? Im writting a script that ill automoate to apper every wednesday asking for the trash to be aken out and when you hit ok the dialoge pops up asking for the password and an aadult would type in the pass and itll go back to normal. Thanks alot.
One more question

tell application "Mail"
message
subject "userresponse"
content
mailto "fivetoadsloth@gmail.com"

end tell

What is wrong with that? what the goal is is to send an email to myself with the userreponse in a dialog above. Thanks SO much.
my goal is to mkae the subject the user response and have no content. (Im expecting the user response to be fairly short, 6-7 characters)



iMeowbot
Dec 29, 2006, 03:20 PM
For a Q&D approach, you might abuse the do shell script (http://developer.apple.com/technotes/tn2002/tn2065.html) admin privs toy.

fivetoadsloth
Dec 30, 2006, 09:41 AM
tell application "Mail"
message
subject "userresponse"
content
mailto "fivetoadsloth@gmail.com"

end tell


What is wrong with that? it is supposed to send a user response to my email adressas the subject and have no message.
Thanks alot

Unorthodox
Dec 30, 2006, 12:55 PM
What is wrong with that? it is supposed to send a user response to my email adressas the subject and have no message.
Thanks alot
Pretty much everything.
Try this...
tell application "Mail"
activate
set newMessage to make new outgoing message
tell newMessage
set subject to "userresponse"
set content to ""
make new to recipient with properties {address:"fivetoadsloth@gmail.com"}
end tell
send newMessage
end tell

And as for the password thingy. Is this what you want?
set the_password to "password" --set this to the password you want to use

set correct_pass to false
set the_dialog to "Please enter your password:"
repeat while correct_pass is false
display dialog the_dialog default answer "" buttons {"Cancel", "OK"} default button 2 with icon 0 with hidden answer
if the text returned of the result is the_password then
tell application "Finder"
set correct_pass to true
empty the trash
end tell
else
beep
set the_dialog to "Incorrect password." & return & "Please enter your password:"
end if
end repeat

fivetoadsloth
Dec 30, 2006, 02:27 PM
Thanks SO much!!!

KJaques
Jul 1, 2011, 09:10 AM
I searched this thread when I was looking for how to hide the typing when asking for a password. I took it to mean you can't. Later, I found you could, by using the parameters "default answer" and "hidden answer" with "display dialog", as follows:

display dialog "Enter Password" default answer "" with hidden answer