supersonic Posted June 17, 2010 Share Posted June 17, 2010 Hi! May be this was discussed many times... I'm trying to ENTER an input control. In order to work I have to press BACKSPACE or LEFT/RIGHT ARROW first. Here's the sample code: #include <EditConstants.au3> #include <GUIConstantsEx.au3> Local $hGUI = GUICreate("", 200, 100, -1, -1) Local $hGUI_C = GUICtrlCreateInput("X", 1, 1, 198, 21) GUISetState(@SW_SHOW, $hGUI) While 1 Local $msg = GUIGetMsg(1) Switch $msg[1] Case $hGUI Switch $msg[0] Case $GUI_EVENT_CLOSE ExitLoop Case $hGUI_C _test() EndSwitch EndSwitch WEnd GUIDelete($hGUI) Exit Func _test() MsgBox(0, "", "", 0, GUICreate("")) EndFunc Please, could somebody help me? Greets, -supersonic. Link to comment Share on other sites More sharing options...
water Posted June 17, 2010 Share Posted June 17, 2010 What do you want to achieve with your code? The GUI now displays an input control with the content ("X") already selected. Why dow you want to press BACKSPACE or LEFT/RIGHT ARROW first? My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
bogQ Posted June 17, 2010 Share Posted June 17, 2010 (edited) There are probably other easyer wayes that arnt so brutali like thisone (like focusing on defolt button on enter), You can do it like this #include <EditConstants.au3> #include <GUIConstantsEx.au3> #Include <Misc.au3> Local $hGUI = GUICreate("test", 200, 100, -1, -1) Local $hGUI_C = GUICtrlCreateInput("Working ENTER", 1, 1, 198, 21) Local $hGUI_D = GUICtrlCreateInput("...", 1, 20, 198, 21) GUISetState(@SW_SHOW, $hGUI) While 1 If _IsPressed("0D") And WinActive("test") And ControlGetFocus("test") = "Edit1" Then _test() EndIf Local $msg = GUIGetMsg(1) Switch $msg[1] Case $hGUI Switch $msg[0] Case $GUI_EVENT_CLOSE ExitLoop Case $hGUI_C EndSwitch EndSwitch WEnd GUIDelete($hGUI) Exit Func _test() MsgBox(0, "", "", 0, GUICreate("")) EndFunc Edited June 17, 2010 by bogQ TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost. Link to comment Share on other sites More sharing options...
supersonic Posted June 17, 2010 Author Share Posted June 17, 2010 The input has the focus. I just want to press enter and - depending on the input data - an action starts... Currently - in order to work - I first have to press BACKSPACE or LEFT/RIGHT ARROW within the input control. Without, nothing happens... I have changed the sample code: #include <EditConstants.au3> #include <GUIConstantsEx.au3> Local $hGUI = GUICreate("", 200, 100, -1, -1) Local $hGUI_C = GUICtrlCreateInput("", 1, 1, 198, 21) GUISetState(@SW_SHOW, $hGUI) While 1 Local $msg = GUIGetMsg(1) Switch $msg[1] Case $hGUI Switch $msg[0] Case $GUI_EVENT_CLOSE ExitLoop Case $hGUI_C _test() EndSwitch EndSwitch WEnd GUIDelete($hGUI) Exit Func _test() Local $sTmp = GUICtrlRead($hGUI_C, 0) If Not $sTmp Then MsgBox(0, "", "Input control empty.") Else MsgBox(0, "", $sTmp) EndIf EndFunc Link to comment Share on other sites More sharing options...
supersonic Posted June 17, 2010 Author Share Posted June 17, 2010 @bogQ - Thank you, I will give it a try... 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