totaln00ber Posted March 1, 2007 Share Posted March 1, 2007 Hey experts, Trying to assign the enter key to different inputs/textboxes so that when the enter key is pressed on a specific textbox, it runs one function. Pressing the enter key on another textbox it goes to another function. I don't want the user to have to click a submit button or tab to it and press enter. Didn't find anything under the help files under "Edit/Input Styles", the closest thing was $ES_WANTRETURN Any suggestions? Thanks! Link to comment Share on other sites More sharing options...
xcal Posted March 1, 2007 Share Posted March 1, 2007 #include <GUIConstants.au3> GUICreate('Inputs', 140, 100) $input1 = GUICtrlCreateInput('', 10, 10, 120, 20) $input2 = GUICtrlCreateInput('', 10, 40, 120, 20) $input3 = GUICtrlCreateInput('', 10, 70, 120, 20) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $input1 MsgBox(0, '', GUICtrlRead($input1)) Case $input2 MsgBox(0, '', GUICtrlRead($input2)) Case $input3 MsgBox(0, '', GUICtrlRead($input3)) EndSwitch WEnd ; If you have default text in the input it doesn't work until it's changed. ; If text is highlighted, it won't work. ; If it's the default text, it needs to be unhighlighted AND changed. ; Maybe someone can explain what I'm doing wrong to cause the above. How To Ask Questions The Smart Way Link to comment Share on other sites More sharing options...
totaln00ber Posted March 1, 2007 Author Share Posted March 1, 2007 Hmmm, that's a good start. But when you type something into the first textbox and then press TAB to go to the next one, it runs the function as well. So it looks like the GUIGetMsg() listens for the TAB key as well; can it be disable and just listen for the ENTER key? Link to comment Share on other sites More sharing options...
BrettF Posted March 1, 2007 Share Posted March 1, 2007 Hmmm, that's a good start. But when you type something into the first textbox and then press TAB to go to the next one, it runs the function as well.So it looks like the GUIGetMsg() listens for the TAB key as well; can it be disable and just listen for the ENTER key?Case $input AND _IsPressed ??? Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
totaln00ber Posted March 1, 2007 Author Share Posted March 1, 2007 Case $input AND _IsPressed ???#include <GUIConstants.au3> #include <Misc.au3> $dll = DllOpen("user32.dll") GUICreate('Inputs', 140, 100) $input1 = GUICtrlCreateInput('', 10, 10, 120, 20) $input2 = GUICtrlCreateInput('', 10, 40, 120, 20) $input3 = GUICtrlCreateInput('', 10, 70, 120, 20) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $input1 If _IsPressed("0D", $dll) Then MsgBox(0, '', GUICtrlRead($input1)) EndIf Case $input2 If _IsPressed("0D", $dll) Then MsgBox(0, '', GUICtrlRead($input2)) EndIf Case $input3 If _IsPressed("0D", $dll) Then MsgBox(0, '', GUICtrlRead($input3)) EndIf EndSwitch WEnd Didn't work; not sure if the code structure is correct though. Link to comment Share on other sites More sharing options...
xcal Posted March 1, 2007 Share Posted March 1, 2007 Hmm that tab thing is kind of strange. I guess input sends a message when it's focused with tab. Anyway, you could try this: #include <GUIConstants.au3> #include <Misc.au3> GUICreate('Inputs', 140, 100) $input1 = GUICtrlCreateInput('', 10, 10, 120, 20) $input2 = GUICtrlCreateInput('', 10, 40, 120, 20) $input3 = GUICtrlCreateInput('', 10, 70, 120, 20) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $input1 If Not _IsPressed('09') Then MsgBox(0, '', GUICtrlRead($input1)) Case $input2 If Not _IsPressed('09') Then MsgBox(0, '', GUICtrlRead($input2)) Case $input3 If Not _IsPressed('09') Then MsgBox(0, '', GUICtrlRead($input3)) EndSwitch WEnd How To Ask Questions The Smart Way Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 1, 2007 Moderators Share Posted March 1, 2007 #include <GUIConstants.au3> #include <Misc.au3> $hWndGUI = GUICreate('Inputs', 140, 100) $input1 = GUICtrlCreateInput('', 10, 10, 120, 20) $input2 = GUICtrlCreateInput('', 10, 40, 120, 20) $input3 = GUICtrlCreateInput('', 10, 70, 120, 20) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch If _IsPressed('0D') Then Switch ControlGetFocus($hWndGUI) Case 'Edit1' MsgBox(0, '$input1', GUICtrlRead($input1)) Case 'Edit2' MsgBox(0, '$input2', GUICtrlRead($input2)) Case 'Edit3' MsgBox(0, '$input3', GUICtrlRead($input3)) EndSwitch Sleep(250) EndIf WEnd Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. 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