carteblanche619 Posted December 15, 2013 Posted December 15, 2013 Why is this code not working the way its supposed to??? Where am I going wrong??? Plz Helpexpandcollapse popup#include <Constants.au3> #include <GuiToolbar.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GuiStatusBar.au3> #include <ProgressConstants.au3> #include <StaticConstants.au3> #include <TabConstants.au3> #include <WindowsConstants.au3> #include <IE.au3> #include <String.au3> #include <Misc.au3> #Region ### START Koda GUI section ### Form= $FirstRun = GUICreate("Dialog", 306, 226, 346, 262, BitOR($WS_SYSMENU,$WS_POPUP)) GUICtrlCreateGroup("", 8, 1, 289, 185) GUICtrlCreateLabel("Welcome User,", 24, 16, 77, 17) GUICtrlCreateLabel("Kindly enter a password", 24, 72, 219, 17) $FirstRunPass1 = GUICtrlCreateInput("", 32, 96, 241, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER,$ES_PASSWORD)) $FirstRunPass2 = GUICtrlCreateInput("", 32, 152, 241, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER,$ES_PASSWORD)) GUICtrlCreateLabel("Re-enter the same password again", 24, 128, 168, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $OK = GUICtrlCreateButton("&OK", 65, 195, 75, 25) $Cancel = GUICtrlCreateButton("&Cancel", 162, 195, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE, $Cancel Exit Case $OK, _IsPressed("0D") $FirstRunPass1Value = GUICtrlRead($FirstRunPass1) $FirstRunPass2Value = GUICtrlRead($FirstRunPass2) $Match = StringCompare($FirstRunPass1Value, $FirstRunPass2Value,1) If $Match = 0 Then MsgBox(64, "Done", "Passwords match successfully.") ;;Do Something Exit Else MsgBox(16, "Error", "Passwords don't match. Please enter again") EndIf EndSwitch WEnd
carteblanche619 Posted December 15, 2013 Author Posted December 15, 2013 Sorry about the number of includes...this code is a part from large piece of code :/
Developers Jos Posted December 15, 2013 Developers Posted December 15, 2013 Why is this code not working the way its supposed to??? Where am I going wrong??? Plz Help Care to share what the code is supposed to do that isn't working or are you expecting us to just understand? Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
carteblanche619 Posted December 15, 2013 Author Posted December 15, 2013 What? When you launch this code, it terminates saying Passwords don't match successfully while what I want is that it should wait until I press OK or Enter("_IsPressed("0D")")
BugFix Posted December 15, 2013 Posted December 15, 2013 I think you have a problem in this line: Case $OK, _IsPressed("0D") You can not ask for _IsPressed() with GuiGetMsg(). You must ask for _IsPressed outside the switch-statement. Best Regards BugFix
Developers Solution Jos Posted December 15, 2013 Developers Solution Posted December 15, 2013 What? When you launch this code, it terminates saying Passwords don't match successfully while what I want is that it should wait until I press OK or Enter("_IsPressed("0D")") Not sure why you first ask what I want and then still supply the answer to the question... Get rid of the _IsPressed() on the case statement and set the OK button as default so when you press Enter you also fire the Ok button. Jos carteblanche619 1 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
carteblanche619 Posted December 15, 2013 Author Posted December 15, 2013 But this works perfectly fineexpandcollapse popup#include <Constants.au3> #include <GuiToolbar.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GuiStatusBar.au3> #include <ProgressConstants.au3> #include <StaticConstants.au3> #include <TabConstants.au3> #include <WindowsConstants.au3> #include <IE.au3> #include <String.au3> #include <Misc.au3> #Region ### START Koda GUI section ### Form= $FirstRun = GUICreate("Dialog", 306, 226, 346, 262, BitOR($WS_SYSMENU,$WS_POPUP)) GUICtrlCreateGroup("", 8, 1, 289, 185) GUICtrlCreateLabel("Welcome User,", 24, 16, 77, 17) GUICtrlCreateLabel("Kindly enter a password", 24, 72, 219, 17) $FirstRunPass1 = GUICtrlCreateInput("", 32, 96, 241, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER,$ES_PASSWORD)) $FirstRunPass2 = GUICtrlCreateInput("", 32, 152, 241, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER,$ES_PASSWORD)) GUICtrlCreateLabel("Re-enter the same password again", 24, 128, 168, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $OK = GUICtrlCreateButton("&OK", 65, 195, 75, 25) $Cancel = GUICtrlCreateButton("&Cancel", 162, 195, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Select Case $nMsg = $GUI_EVENT_CLOSE Or $nMsg = $Cancel Exit Case $nMsg = $OK Or _IsPressed("0D") $FirstRunPass1Value = GUICtrlRead($FirstRunPass1) $FirstRunPass2Value = GUICtrlRead($FirstRunPass2) $Match = StringCompare($FirstRunPass1Value, $FirstRunPass2Value,1) If $Match = 0 Then MsgBox(64, "Done", "Passwords match successfully.") ;;Do Something Exit Else MsgBox(16, "Error", "Passwords don't match. Please enter again") EndIf EndSelect The reason I am switching from select case to switch case for all GUIs is that I am trying to handle multiple GUIs...so I cannot use switch somewhere and somewhere select...so I have to make this work out using switch
carteblanche619 Posted December 15, 2013 Author Posted December 15, 2013 KK... $BS_DEFPUSHBUTTON worked fine for me Thanks Jos ***Solved***
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