xuzo Posted July 12, 2012 Share Posted July 12, 2012 (edited) Playing with Koda and GUI today , first time ever. Trying to understand the very, very, very basic, like: 1. Someone enters their name in input field 2. Pop up their name in message box #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #region ### START Koda GUI section ### Form= Local $Form1 = GUICreate("Form1", 466, 202, 192, 114) Local $Name = GUICtrlCreateLabel("Name", 120, 120, 36, 17) Local $NamePlease = GUICtrlCreateInput("NamePlease", 176, 120, 121, 21) Local $Submit = GUICtrlCreateButton("Submit", 328, 120, 75, 25) GUISetState(@SW_SHOW) #endregion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $NamePlease MsgBox(64, "Your name is", $NamePlease) EndSwitch WEnd If possible please just correct this very basic code example without complicated variables...will just confuse me! Edited July 12, 2012 by xuzo Link to comment Share on other sites More sharing options...
Zedna Posted July 12, 2012 Share Posted July 12, 2012 (edited) Case $Submit MsgBox(64, "Your name is", GUICtrlRead($NamePlease)) Edited July 12, 2012 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Bowmore Posted July 12, 2012 Share Posted July 12, 2012 You need to use the function GuiCtrlRead() to get the content of controls. The variables such as $NamePlease contain only the ID of the control which is why you were seeing the number 4 in the message box rather than the entered name. I've corrected your script and added a line to display the message if the user clicks on the submit button #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #region ### START Koda GUI section ### Form= Local $Form1 = GUICreate("Form1", 466, 202, 192, 114) Local $Name = GUICtrlCreateLabel("Name", 120, 120, 36, 17) Local $NamePlease = GUICtrlCreateInput("NamePlease", 176, 120, 121, 21) Local $Submit = GUICtrlCreateButton("Submit", 328, 120, 75, 25) GUISetState(@SW_SHOW) #endregion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $NamePlease MsgBox(64, "Your name is", GuiCtrlRead($NamePlease)) Case $Submit MsgBox(64, "Your name is", GuiCtrlRead($NamePlease)) EndSwitch WEnd "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook Link to comment Share on other sites More sharing options...
xuzo Posted July 12, 2012 Author Share Posted July 12, 2012 Thanks everyone! works fine! 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