AppleScript password

Discussion in 'Mac Programming' started by fivetoadsloth, Dec 29, 2006.

  1. macrumors 65816

    fivetoadsloth

    Joined:
    Aug 15, 2006
    #1
    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

    Code:
    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)
     
  2. macrumors G3

    iMeowbot

    Joined:
    Aug 30, 2003
    #2
    For a Q&D approach, you might abuse the do shell script admin privs toy.
     
  3. thread starter macrumors 65816

    fivetoadsloth

    Joined:
    Aug 15, 2006
    #3
    Code:
    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
     
  4. macrumors 65816

    Unorthodox

    Joined:
    Mar 3, 2006
    Location:
    Not at the beach...
    #4
    Pretty much everything.
    Try this...
    Code:
    tell application "Mail" 
            activate
            set newMessage to make new outgoing message
            tell newMessage
                set subject to "[I][B]userresponse[/B][/I]"
                set content to ""
                make new to recipient with properties {address:"[I][B]fivetoadsloth@gmail.com[/B][/I]"}
            end tell
            send newMessage
    end tell
    And as for the password thingy. Is this what you want?
    Code:
    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
     
  5. thread starter macrumors 65816

    fivetoadsloth

    Joined:
    Aug 15, 2006
    #5
    Thanks SO much!!!
     
  6. macrumors newbie

    Joined:
    Mar 4, 2009
    #6
    Hiding Typing

    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
     

Share This Page