EarlDPearl Posted February 7, 2012 Share Posted February 7, 2012 How does one modify a GUICTRLINPUT box so that either the Tab or Enter key completes the operation and moves along to the next box. Maybe it is not modifiable and one has to create a completely new function. I went looking for the GUICTRLINPUT source to modify but cannot seem to find it. All input boxes in my application are numeric and most people inputting will have numberic keyboards and will want use the numeric keyboard Enter key. Will appreciate help ... Thanks ... Earl Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 7, 2012 Moderators Share Posted February 7, 2012 EarlDPearl,Welcome to the AutoIt forum. A quick way to do what you want is to use an Accelerator key so that the {ENTER} key acts as a {TAB} key and moves the focus onto the next input:#include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 500, 500) $hInput_1 = GUICtrlCreateInput("", 10, 10, 200, 20) $hInput_2 = GUICtrlCreateInput("", 10, 50, 200, 20) $hInput_3 = GUICtrlCreateInput("", 10, 90, 200, 20) $hDummy = GUICtrlCreateDummy() GUISetState() Local $aAccelKeys[1][2] = [["{ENTER}", $hDummy]] GUISetAccelerators($aAccelKeys) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hDummy Send("{TAB}") EndSwitch WEndYou could easily improve this by adding some errorchecking to see if all the inputs were completed and then using {ENTER} to move to the next action, but that can come later. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
EarlDPearl Posted February 8, 2012 Author Share Posted February 8, 2012 Thanks for the quick reply ... off to work now. Link to comment Share on other sites More sharing options...
EarlDPearl Posted February 8, 2012 Author Share Posted February 8, 2012 I tranlated your example into an event driven scheme and it works very well. Thanks loads... Earl Solved Link to comment Share on other sites More sharing options...
czardas Posted November 28, 2012 Share Posted November 28, 2012 (edited) The code is messed up. This is a result of several upgrades to the forum software, which has been affecting the code boxes. It is best to first click the AutoIt code button and add the AutoIt tags to your post without any code. Then paste your code directly between the tags. This generally works all the time. Edited November 28, 2012 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
ravaged1 Posted November 29, 2012 Share Posted November 29, 2012 (edited) I know this is and old thread, but I'm working on this same thing now and if I do it this way I loose the ability to use the enter button on GUICtrlcreateButton's. here is mine below. expandcollapse popup#include <File.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $Save = "1" #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 592, 320, 488, 249) $Input1_sku = GUICtrlCreateInput("", 72, 56, 233, 32) GUICtrlSetFont(-1, 16, 400, 0, "MS Sans Serif") $Input2_qty = GUICtrlCreateInput("", 72, 144, 233, 32, $ES_NUMBER) GUICtrlSetFont(-1, 16, 400, 0, "MS Sans Serif") $Label1 = GUICtrlCreateLabel("SKU:", 8, 56, 46, 28) GUICtrlSetFont(-1, 16, 400, 0, "MS Sans Serif") $Label2 = GUICtrlCreateLabel("QTY:", 8, 144, 48, 28) GUICtrlSetFont(-1, 16, 400, 0, "MS Sans Serif") $Enter = GUICtrlCreateButton("Enter", 120, 224, 123, 33, $WS_GROUP) GUICtrlSetFont(-1, 16, 400, 0, "MS Sans Serif") $hDummy = GUICtrlCreateDummy() ;Comment out for testing Enter with gui buttons. GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Local $aAccelKeys[1][2] = [["{ENTER}", $hDummy]] ;==>Comment out for testing Enter with gui buttons. GUISetAccelerators($aAccelKeys) ;==>Comment out for testing Enter with gui buttons. While 1 $nMsg = GUIGetMsg() If $nMsg = $Enter Then _Enter() If $nMsg = $Save Then _Save() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $hDummy ;==>;Comment out for testing Enter with gui buttons. Send("{TAB}") ;==>;Comment out for testing Enter with gui buttons. EndSwitch WEnd Func _Enter() $Label3 = GUICtrlCreateLabel("SKU: " & GUICtrlRead($Input1_sku), 344, 56, 220, 25) GUICtrlSetFont(-1, 16, 400, 0, "MS Sans Serif") $Label4 = GUICtrlCreateLabel("QTY: " & GUICtrlRead($Input2_qty), 344, 144, 220, 25) GUICtrlSetFont(-1, 16, 400, 0, "MS Sans Serif") $Save = GUICtrlCreateButton("Save", 368, 224, 137, 33, $WS_GROUP) GUICtrlSetFont(-1, 16, 400, 0, "MS Sans Serif") EndFunc ;==>_Enter Func _Save() Local $file = FileOpen("Audit_" & @YEAR & ".csv", 1) ;==>Comment out to disable file creation. FileWriteLine($file, GUICtrlRead($Input1_sku) & ", " & GUICtrlRead($Input2_qty)) ;==>Comment out to disable file creation. _SelfRestart() EndFunc ;==>_Save Func _SelfRestart() If @Compiled Then Run(FileGetShortName(@ScriptFullPath)) Else Run(FileGetShortName(@AutoItExe) & " " & FileGetShortName(@ScriptFullPath)) EndIf Exit EndFunc ;==>_SelfRestart Edited November 29, 2012 by ravaged1 Link to comment Share on other sites More sharing options...
ravaged1 Posted November 29, 2012 Share Posted November 29, 2012 (edited) Sorry have not been around here in a while. Basicly with code in my post above, Im looking to just make a fast little app that will play nice with the keyboard, mouse, and a barcode scanner. keyboard enter key for buttons will not work becuase I set it up for inputs(barcode scanner). I'm not sure how to get them all working right together. Edited November 29, 2012 by ravaged1 Link to comment Share on other sites More sharing options...
czardas Posted November 29, 2012 Share Posted November 29, 2012 (edited) I don't really understand this thread. Enter is normally used to activate the button which has focus. Altering this makes no sense to me. There are a whole load of other keys available that could be used as accelerators. You can set a particular button to be the default push button when you create it, by using $BS_DEFPUSHBUTTON. Edited November 29, 2012 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
ravaged1 Posted November 29, 2012 Share Posted November 29, 2012 (edited) I don't really understand this thread. Enter is normally used to activate the button which has focus. Altering this makes no sense to me. There are a whole load of other keys available that could be used as accelerators. You can set a particular button to be the default push button when you create it, by using $BS_DEFPUSHBUTTON.When you use a barcode scanner or type in a field it's normal to use the enter key to move to the next feild or button even.After setting the ENTER key to TAB with $aAccelKeys, enter will no longer work for buttons. So I'm asking if anyone knows a better way to do what I'm looking for. Edited November 29, 2012 by ravaged1 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