saldous Posted February 18, 2007 Share Posted February 18, 2007 Hi, I'm after some help in writing a utility to do the following: 1) Display a message box asking a user to input their email address and a password. 2) Take this input from the user and pass it to the command line to install an application like this: msiexec /i program.msi EMAILADDRESS=UserInput1 PASSWORD=UserInput2 How do I do this? It sounds simple but I'm completely stuck and I'm new to AutoIT so I would appreciate any help from all you experienced scripters out there. Thanks in advance. Link to comment Share on other sites More sharing options...
lod3n Posted February 18, 2007 Share Posted February 18, 2007 Take a look in the helpfile at the commands InputBox and Run. That's all you need. [font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font] Link to comment Share on other sites More sharing options...
Ayush Posted February 18, 2007 Share Posted February 18, 2007 GUICreate("Enter EMail/Password :",250,90) GUICtrlCreateLabel ("Email:",10, 10,60,21) $E=GUICtrlCreateEdit ("", 70, 6,175,19) GUICtrlCreateLabel ("Password:", 10, 36,60,21) $P=GUICtrlCreateEdit ("", 70,32,175,21) $K=GUICtrlCreateButton("OK",100,60,50) GUISetState(@SW_Show) While 1 $msg = GUIGetMsg() Select Case $msg=-3 ExitLoop Case $msg=$K Run("msiexec /i program.msi EMAILADDRESS=" & GUICtrlRead($E) & "PASSWORD=" & GUICtrlRead($P)) EndSelect WEnd Link to comment Share on other sites More sharing options...
saldous Posted February 19, 2007 Author Share Posted February 19, 2007 (edited) Wow, thanks, I'd been working on something for ages trying to figure this out and you made it so simple! However I've got a few more questions: 1) I want to be able to stop the user leaving either of the fields blank, i.e they must enter something. I can do this using the InputBox command (by putting in " M", but can't work out how to do it using GUICtrlCreateEdit. Any ideas? 2) On the password field, I want the password to be displayed as "*" instead of the actual password, I've tried adding in the $ES_PASSWORD command but it errors out when converting the script to an EXE 3) A nice to have: I would like to put in a pasword verification, make the user type it in again and then check it is the same as the one previously entered, if it isn't correct the "OK" button should give an error until the passwords match. 4) Also, how do I make the text input box only one line stopping the user pressing enter generating more lines and the scroll bars? This is as far as I had got myself: CODE;Install Script v0.8 ;User enters email address $email = InputBox("My Application Install Package:", "Enter your email address", "", " M", _ 400, -1) ;User enters password $passwd = InputBox("Application Install is 25% complete", "Choose a password to protect your account.", "", "*M8", _ 400, -1) ;Install Application using user input fields Run("msiexec /i program.msi EMAILADDRESS=" & GUICtrlRead($email) & "PASSWORD=" & GUICtrlRead($passwd)) Thanks for your help once again. Edited February 19, 2007 by saldous Link to comment Share on other sites More sharing options...
saldous Posted February 19, 2007 Author Share Posted February 19, 2007 also, in my script the "Cancel" button doesn't actually cancel out and end the program. How do I do this? Link to comment Share on other sites More sharing options...
saldous Posted February 19, 2007 Author Share Posted February 19, 2007 ok, I'm getting closer, I've got the password verification working, last thing to do is to get the cancel button to exit the application: CODE; Install Script v0.8 ; User enters email address $email = InputBox("Application Install Package", "Enter your email address", "", " M", _ 400, -1) ; Start loop to ensure user enters the same password twice $bLoop = 1 While $bLoop = 1 ; User enters password $passwd = InputBox("Application Install Package 25% complete", "Choose a password to protect your account.", "", "*M8", _ 400, -1) ; 2nd password box to check it matches the first $passwd2 = InputBox("Application Install Package", "Please re-type your password for verification", "", "*M8", _ 400, -1) If @error = 1 Then MsgBox(4096, "Error", "You pressed 'Cancel' - Please try again!") Else ; They clicked OK, but did they type the right thing? If $passwd2 <> $passwd Then MsgBox(4096, "Error", "Your passwords do not match - please try again!") Else $bLoop = 0 EndIf EndIf WEnd ; Prompt the user to install or not - use a Yes/No prompt $answer = MsgBox(4, "Start Installation", "Click on YES to start the install") ; Check the user's answer to the prompt ; If "No" was clicked (7) then exit the script If $answer = 7 Then MsgBox(4096, "", "Install cancelled.") Exit EndIf ;Install Application using user enter parameters Run("msiexec /i program.msi EMAILADDRESS=" & GUICtrlRead($email) & "PASSWORD=" & GUICtrlRead($passwd)) ; Finished! Link to comment Share on other sites More sharing options...
saldous Posted February 19, 2007 Author Share Posted February 19, 2007 I got it working now, thanks all. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now