joseLB Posted July 29, 2008 Share Posted July 29, 2008 Hi allI need to make a button to receive focus, after some user input in other input fields.I tried GUICtrlSetState($btScan,$GUI_FOCUS), or ControlFocus($titA0FasEntry,"","Button1") and nothing makes the button to receive focus so I could type <enter> to execute it.The point is that I'm doing a small numeric dataentry system, with 2 numeric fields and a button, and the desirable sequence is:user types the numbers in an input field in numpad keyboard and press <enter>,the next input field be the selected one, and user again types numbers and <enter>a button is selected so that if user types <enter>, the button does it activities.the 1st input field becomes the focused one again and all the sequence repeats.For the input fields, GUICtrlSetState($scanFim,$GUI_FOCUS) works fine, they receive focus and <enter> work fine, but for the button it does nothing...ThanksJose Link to comment Share on other sites More sharing options...
JustinMeyer Posted July 29, 2008 Share Posted July 29, 2008 There is probably a far better way but.... what if you set "enter" as a hot key to run a function that contains an "if" statement. I would think you could use "ControlGetFocus" to find out what step you are at and take the appropriate action, set focus to control or run function. Link to comment Share on other sites More sharing options...
joseLB Posted July 29, 2008 Author Share Posted July 29, 2008 Thanks JMeyer, that's a good solution! But I'm guessing why the button does not receive focus as the input fileds receive. That can be considered a bug? Link to comment Share on other sites More sharing options...
JustinMeyer Posted July 29, 2008 Share Posted July 29, 2008 You can set the state of a button to "$BS_DEFPUSHBUTTON", this will cause the same action as pressing the button would but by pressing enter. But I would think just setting the the enter key to run a function would better serve your situation. Link to comment Share on other sites More sharing options...
joseLB Posted July 29, 2008 Author Share Posted July 29, 2008 you'r right, "...just setting the the enter key to run a function would better serve your situation... as $BS_DEFPUSHBUTTON seems to me would do that button the permanent default to <enter> key... Thanks again, Jose Link to comment Share on other sites More sharing options...
BrettF Posted July 29, 2008 Share Posted July 29, 2008 Very Basic: expandcollapse popup#include <GUIConstants.au3> HotKeySet("{ENTER}", "SelectControl") Global $controled = 1 #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("AForm1", 135, 136, 193, 115) $Input1 = GUICtrlCreateInput("AInput1", 8, 8, 121, 21) $Input2 = GUICtrlCreateInput("AInput2", 8, 40, 121, 21) $Input3 = GUICtrlCreateInput("AInput3", 8, 72, 121, 21) $Button1 = GUICtrlCreateButton("AButton1", 56, 104, 75, 25, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func SelectControl() If WinActive($Form1) Then If $controled = 1 Then GUICtrlSetState($Input2, $GUI_FOCUS) $controled = 2 ElseIf $controled = 2 Then GUICtrlSetState($Input3, $GUI_FOCUS) $controled = 3 ElseIf $controled = 3 Then GUICtrlSetState($Button1, $GUI_FOCUS) $controled = 4 ElseIf $controled = 4 Then GUICtrlSetState($Input1, $GUI_FOCUS) $controled = 1 _InsertData() EndIf EndIf EndFunc ;==>SelectControl Func _InsertData() $1 = GUICtrlRead($Input1) $2 = GUICtrlRead($Input2) $3 = GUICtrlRead($Input3) MsgBox(0, "Results", "1 = " & $1 & @CRLF & "2 = " & $2 & @CRLF & "3 = " & $3) EndFunc ;==>_InsertData Other things you could add are the likes of getting the current control focus and such. Hope it gives you a start 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...
joseLB Posted July 29, 2008 Author Share Posted July 29, 2008 Thanks Brett and jMeyer. I will go with hotkeyset..Jose 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