saldous Posted August 25, 2009 Share Posted August 25, 2009 Hope someone can help here:My script puts a GUI up with two buttons, "Exit" and "Install"I don't have any code using the _IsPressed command, yet whilst the GUI is up if I press the Enter key on my keyboard the script exits.I'm assuming this is because the Exit button (which does exit the script) is selected by default somehow. I tried changing this to the other button but I still can't get it to work. Ideas?expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Include <Misc.au3> ; Create UI with input boxes to capture user details $Form1 = GUICreate("Installation utility", 429, 218, 368, 197, BitOR($WS_SYSMENU,$WS_CAPTION,$WS_POPUP,$WS_POPUPWINDOW,$WS_BORDER,$WS_CLIPSIBLINGS), BitOR($WS_EX_TOPMOST,$WS_EX_WINDOWEDGE)) $EmailInput = GUICtrlCreateInput ("", 184, 23, 217, 21) $pw1 = GUICtrlCreateInput("", 184, 71, 217, 21) $pw2 = GUICtrlCreateInput("", 184, 118, 217, 21) $InstallButton = GUICtrlCreateButton("Install", 240, 176, 75, 25, BitOR($BS_DEFPUSHBUTTON,$WS_GROUP)) $ExitButton = GUICtrlCreateButton("Exit", 104, 176, 75, 25, BitOR($BS_DEFPUSHBUTTON,$WS_GROUP)) $Label1 = GUICtrlCreateLabel("Enter the users email address:", 32, 24, 145, 17) $Label2 = GUICtrlCreateLabel("Enter a password for this account:", 16, 72, 165, 17) $Label3 = GUICtrlCreateLabel("(min 8 characters)", 48, 88, 88, 17) $Label4 = GUICtrlCreateLabel("(e.g. user@company.com)", 40, 40, 128, 17) $Label5 = GUICtrlCreateLabel("Confirm password:", 88, 120, 90, 17) GUISetState(@SW_SHOW) $completed = 0 While 1 $msg = GUIGetMsg() Select ; Exit if the user closes the dialogue box or clicks on Exit button Case $msg = $GUI_EVENT_CLOSE Or $msg = $ExitButton Exit ; Exit if the installation process completed Case $completed = 1 Exit ; Validate that the two passwords entered match Case $msg = $InstallButton If (GUICtrlRead($pw1)) == (GUICtrlRead($pw2)) and (GUICtrlRead($EmailInput)) <> "" then MsgBox(262144, "Installing...", "Using this email address: " & GUICtrlRead($EmailInput) & @CRLF & " and this password: " & GUICtrlRead($pw1)) ;need to write command line part still $completed = 1 ElseIF (GUICtrlRead($pw1)) <> (GUICtrlRead($pw2)) then MsgBox(262144+48, "Password error", "Passwords do not match, please try again.") $completed = 0 ElseIf (GUICtrlRead($EmailInput)) == "" then MsgBox(262144+48, "Email address error", "Please enter an email address and try again.") $completed = 0 EndIf EndSelect WEnd Link to comment Share on other sites More sharing options...
Info Posted August 25, 2009 Share Posted August 25, 2009 Remove the '$BS_DEFPUSHBUTTON' style from your exit button. You can remove it from the install button as well. expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Include <Misc.au3> ; Create UI with input boxes to capture user details $Form1 = GUICreate("Installation utility", 429, 218, 368, 197, BitOR($WS_SYSMENU,$WS_CAPTION,$WS_POPUP,$WS_POPUPWINDOW,$WS_BORDER,$WS_CLIPSIBLINGS), BitOR($WS_EX_TOPMOST,$WS_EX_WINDOWEDGE)) $EmailInput = GUICtrlCreateInput ("", 184, 23, 217, 21) $pw1 = GUICtrlCreateInput("", 184, 71, 217, 21) $pw2 = GUICtrlCreateInput("", 184, 118, 217, 21) $InstallButton = GUICtrlCreateButton("Install", 240, 176, 75, 25, $WS_GROUP) $ExitButton = GUICtrlCreateButton("Exit", 104, 176, 75, 25, $WS_GROUP) $Label1 = GUICtrlCreateLabel("Enter the users email address:", 32, 24, 145, 17) $Label2 = GUICtrlCreateLabel("Enter a password for this account:", 16, 72, 165, 17) $Label3 = GUICtrlCreateLabel("(min 8 characters)", 48, 88, 88, 17) $Label4 = GUICtrlCreateLabel("(e.g. user@company.com)", 40, 40, 128, 17) $Label5 = GUICtrlCreateLabel("Confirm password:", 88, 120, 90, 17) GUISetState(@SW_SHOW) $completed = 0 While 1 $msg = GUIGetMsg() Select ; Exit if the user closes the dialogue box or clicks on Exit button Case $msg = $GUI_EVENT_CLOSE Or $msg = $ExitButton Exit ; Exit if the installation process completed Case $completed = 1 Exit ; Validate that the two passwords entered match Case $msg = $InstallButton If (GUICtrlRead($pw1)) == (GUICtrlRead($pw2)) and (GUICtrlRead($EmailInput)) <> "" then MsgBox(262144, "Installing...", "Using this email address: " & GUICtrlRead($EmailInput) & @CRLF & " and this password: " & GUICtrlRead($pw1)) ;need to write command line part still $completed = 1 ElseIF (GUICtrlRead($pw1)) <> (GUICtrlRead($pw2)) then MsgBox(262144+48, "Password error", "Passwords do not match, please try again.") $completed = 0 ElseIf (GUICtrlRead($EmailInput)) == "" then MsgBox(262144+48, "Email address error", "Please enter an email address and try again.") $completed = 0 EndIf EndSelect WEnd Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 25, 2009 Moderators Share Posted August 25, 2009 saldous,Both your buttons have the $BS_DEFPUSHBUTTON style. From the Help file for GUICtrlCreateButton:$BS_DEFPUSHBUTTON - Creates a push button with a heavy black border. If the button is in a dialog box, the user can select the button by pressing the ENTER key, even when the button does not have the input focus. This style is useful for enabling the user to quickly select the most likely option, or default. You should only ever have one button with this style, but as the Exit button is given this style last, it will react when the Enter key is pressed. Simple solution - remove the $BS_DEFPUSHBUTTON style from the button create code.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
saldous Posted August 25, 2009 Author Share Posted August 25, 2009 Perfect, thanks again >_ 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