caravelman Posted August 8, 2010 Share Posted August 8, 2010 I have two input controls, first with max 2 characters and second with max 5 characters, as soon as user enters two characters in first input control, I want to move him to next Input control without him hitting the tab, How can I do that ? Your help is appreciated. My Code: $caseyear = GUICtrlCreateInput("", 224, 128, 73, 32, $ES_NUMBER) GUICtrlSetLimit($caseyear, 2) $Label3 = GUICtrlCreateLabel("-", 304, 128, 10, 28) $casenum = GUICtrlCreateInput("", 320, 128, 145, 32, $ES_NUMBER) GUICtrlSetLimit($casenum, 5) I want to move to $casenum after I enter two digit for year without hitting TAB key. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 8, 2010 Moderators Share Posted August 8, 2010 caravelman,Welcome to the AutoIt forum. You can do what you want like this:#include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 500, 500) $hInput_1 = GUICtrlCreateInput("", 10, 10, 200, 20) ; Set limit for top input GUICtrlSetLimit(-1, 2) $hInput_2 = GUICtrlCreateInput("", 10, 50, 200, 20) ; Set limit for bottom input GUICtrlSetLimit(-1, 5) GUISetState() ; Set focus to top input GUICtrlSetState($hInput_1, $GUI_FOCUS) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch ; If bottom input is empty If GUICtrlRead($hInput_2) = "" Then ; And top input is full If StringLen(GUICtrlRead($hInput_1)) = 2 Then ; Set focus to bottom input GUICtrlSetState($hInput_2, $GUI_FOCUS) EndIf EndIf WEndNote that we need 2 checks to decide when we need to set focus to the bottom input - if you remove the outer If statement, it does not work as you want. Try it and see! Please ask if you have any questions. M23P.S. If you want a more complicated example - you can look here! expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $iInput_Limit = 2 $hGUI = GUICreate("Demo", 200, 100) $hInput_1 = GUICtrlCreateInput("", 20, 20, 30, 20) GUICtrlSetLimit(-1, $iInput_Limit) $hInput_2 = GUICtrlCreateInput("", 80, 20, 30, 20) GUICtrlSetLimit(-1, $iInput_Limit) $hInput_3 = GUICtrlCreateInput("", 140, 20, 30, 20) GUICtrlSetLimit(-1, $iInput_Limit) $hButton = GUICtrlCreateButton("OK", 60, 60, 80, 30) GUICtrlSetState(-1, $GUI_DISABLE) GUIRegisterMsg($WM_COMMAND, "On_WM_COMMAND") ; 0x0111 GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hButton $sResult = GUICtrlRead($hInput_1) & "-" & GUICtrlRead($hInput_2) & "-" & GUICtrlRead($hInput_3) MsgBox(0, "You have entered", $sResult) EndSwitch ; Enable button when last input filled If StringLen(GUICtrlRead($hInput_3)) = 2 And BitAnd(GUICtrlGetState($hButton), $GUI_DISABLE) = $GUI_DISABLE Then GUICtrlSetState($hButton, $GUI_ENABLE) WEnd Func On_WM_COMMAND($hWnd, $Msg, $wParam, $lParam) $nNotifyCode = BitShift($wParam, 16) $iControlID = BitAnd($wParam, 0x0000FFFF) ; If input filled move focus to next Switch $nNotifyCode Case 0x400 ;$EN_UPDATE If StringLen(GUICtrlRead($iControlID)) = $iInput_Limit Then GUICtrlSetState($iControlID + 1, $GUI_FOCUS) EndSwitch EndFunc 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...
caravelman Posted August 8, 2010 Author Share Posted August 8, 2010 Thank you M23. You have been great help. Caravelman 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