Merko Posted November 7, 2013 Share Posted November 7, 2013 I'm currently working on a script that requires a stub for a secure login system I'll be using $password = "[PASSWORD]" to call the password from another script, on a button click i'd like to display weather the password is right or wrong $password = "[PASSWORD]" Case $msg = $Button_0 if $userinput = $password Then Msgbox(0,"Correct!","Password is correct!") Else MsgBox(0, "Incorrect!","Password is incorrect!") EndIf Basiclly when i press the button no matter what i put in the input box i always get password is incorrect? Any help wil be highly apreciated, new to autoit! Thankyoy Link to comment Share on other sites More sharing options...
FireFox Posted November 7, 2013 Share Posted November 7, 2013 Hi, Welcome to the autoit forum Please take a look at the helpfile for the GUICtrlRead function. Br, FireFox. Link to comment Share on other sites More sharing options...
l3ill Posted November 7, 2013 Share Posted November 7, 2013 Or this Quick & Easy Down & Dirty StringCompare Method... Local $userinput = InputBox("Check PW", "Enter here") $password = "[PASSWORD]" $result = StringCompare($password, $userinput, 2) If $result = 0 Then MsgBox(0, "Correct!", "Password is correct!") Else MsgBox(0, "Incorrect!", "Password is incorrect!") EndIf My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example Link to comment Share on other sites More sharing options...
water Posted November 7, 2013 Share Posted November 7, 2013 BTW: Please give your threads meaningful titles - because everyone on this forum is looking for help (for his scripts) So we know what you are asking for without having to read the whole thread. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Merko Posted November 7, 2013 Author Share Posted November 7, 2013 Or this Quick & Easy Down & Dirty StringCompare Method... Local $userinput = InputBox("Check PW", "Enter here") $password = "[PASSWORD]" $result = StringCompare($password, $userinput, 2) If $result = 0 Then MsgBox(0, "Correct!", "Password is correct!") Else MsgBox(0, "Incorrect!", "Password is incorrect!") EndIf Thanks for your reply, is there a way i can stop the form from closing if the password entered is wrong? Link to comment Share on other sites More sharing options...
water Posted November 7, 2013 Share Posted November 7, 2013 (edited) You have to do it in a loop until the password is correct or the suer cancels the input: Local $password = "[PASSWORD]", $userinput = "" While 1 $userinput = InputBox("Check PW", "Enter here") If @error <> 0 Then Exit $result = StringCompare($password, $userinput, 2) If $result = 0 Then MsgBox(0, "Correct!", "Password is correct!") ExitLoop Else MsgBox(0, "Incorrect!", "Password is incorrect!") EndIf WEnd Edited November 7, 2013 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Solution dreamzboy Posted November 7, 2013 Solution Share Posted November 7, 2013 Try this: #include <GUIConstantsEx.au3> GUICreate ("Password Verification", 300, 150) Local $pw_input, $result, $msg, $verify, $btn Local $password = "password123" ; Password to verify GUISetState () GUICtrlCreateLabel ("Please enter your password:", 30, 30, 200, 20) GUICtrlSetFont (-1, 10) $pw_input = GUICtrlCreateInput ("", 30, 60, 175, 20) $verify = GUICtrlCreateButton ("Verify", 30, 100, 70, 30) GUICtrlSetFont (-1, 10) Do $msg = GUIGetMsg () Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $verify $result = GUICtrlRead ($pw_input) If ($result = $password) Then MsgBox(64, "Correct!", "Password is correct!") Else MsgBox(48, "Incorrect!", "Password is incorrect! Please try again.") EndIf EndSelect Until 0 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