dufran3 Posted July 2, 2007 Share Posted July 2, 2007 I have an input box. i would like to make that field required...is there a special way to do this? The only way that I could think of, is in the while loop, adding a If $inputfield == '' then blah....here is my code... $Main = GUICreate('System ID', 300, 100) Opt("GUICoordMode",1) $CollectSystemID = GUICtrlCreateInput('',100,20,100) $SystemIDLabel = GUICtrlCreateLabel('System ID',30,23) $CollectModality = GUICtrlCreateCombo('CR',100,40,50) GUICtrlSetData(-1,"CT|DR|DX|MG|MR|NM|OT|PT|RF|RG|US|XA") $ModalityLabel = GUICtrlCreateLabel('Modality',30,43) GLOBAL $SystemID = '' $Button_1 = GUICtrlCreateButton ("OK", 225, 60, 0) GUISetState () ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_1 GLOBAL $SystemID = GUICtrlRead($CollectSystemID) GLOBAL $Modality = GUICtrlRead($CollectModality) If $SystemID == '' Then MsgBox(0,'System ID','The System ID is a require field') ExitLoop EndIf WinSetState('PacsScan System ID','',@SW_HIDE) ExitLoop EndSelect Wend The problem is, i don't want to close the GUI if the field is empty, if they click ok and the field is empty, I want it to open a message box saying that the field is required. and then still have the GUI there. If they click the close button. I would like it to just close. -- On a side note, after entering text into the input box, how do I make it so when pressing enter with the gui active, it will press ok. You know what I mean? Instead of having to click the ok button every time? Link to comment Share on other sites More sharing options...
Josbe Posted July 2, 2007 Share Posted July 2, 2007 Remove ExitLoop below the Msgbox().For another thing...just eval the ENTER key when is pressed and include a ExitLoop. AUTOIT > AutoIt docs / Beta folder - AutoIt latest beta Link to comment Share on other sites More sharing options...
Josbe Posted July 2, 2007 Share Posted July 2, 2007 ... If $SystemID == '' Then MsgBox(0,'System ID','The System ID is a require field') EndIf WinSetState('PacsScan System ID','',@SW_HIDE) ExitLoop EndSelect ...Just checking your code. If these lines are the false part, just change to: If $SystemID == '' Then MsgBox(0,'System ID','The System ID is a require field') Else WinSetState('PacsScan System ID','',@SW_HIDE) ExitLoop EndIf AUTOIT > AutoIt docs / Beta folder - AutoIt latest beta Link to comment Share on other sites More sharing options...
thenewkid Posted July 2, 2007 Share Posted July 2, 2007 is this what you mean? #include <GUIConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Test", 187, 115, 193, 115) $Label1 = GUICtrlCreateLabel("Name*", 8, 48, 36, 17) $Input1 = GUICtrlCreateInput("", 56, 40, 121, 21) $Button1 = GUICtrlCreateButton("OK", 56, 72, 75, 25, 0) $Label2 = GUICtrlCreateLabel("", 48, 8, 140, 17) GUICtrlSetColor(-1, 0xFF0000) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $name = GUICtrlRead($Input1) If $name = "" Then GUICtrlSetData($Label2, "You have to enter your name") Else MsgBox(0,"Test",$name) EndIf EndSwitch WEnd some of my scripts check them out and give feedback so i can learn from them :)autoclicker a autoclickernote taker a script to take notes with Link to comment Share on other sites More sharing options...
dufran3 Posted July 2, 2007 Author Share Posted July 2, 2007 yeh, that works. Thanks guys. About the enter key though. Should I just add another Case statement? If So Case $msg = ??? not sure how to eval that enter key there. Link to comment Share on other sites More sharing options...
james3mg Posted July 2, 2007 Share Posted July 2, 2007 yeh, that works. Thanks guys. About the enter key though. Should I just add another Case statement? If So Case $msg = ??? not sure how to eval that enter key there.Set $BS_DEFPUSHBUTTON as the style of your OK button ...? "There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110 Link to comment Share on other sites More sharing options...
dufran3 Posted July 2, 2007 Author Share Posted July 2, 2007 That did it, I should have seen that....:-( 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