Jump to content
Sign in to follow this  

Moving Txt Cursor to next field without tap key

Recommended Posts

I am using GUICtrlcreateinput to capture phone number in three fields. I would like cursor to move by itself from one filed to next once first field is filled. I have used Mousemove(x,y). This moves the mouse position not the txt cursor position. Any help is appreciated.

Share this post

Link to post
Share on other sites


Welcome to the AutoIt forums. :)

Something like this should help: :)

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>

; Sett he character limits for the 3 inputs
Global $aInput_Limit[3] = [3, 4, 6], $iIndex = 0

$hGUI = GUICreate("Input Autofocus", 500, 500)

$cInput_0 = GUICtrlCreateInput("", 20, 20, 30, 20)
GUICtrlSetLimit($cInput_0, $aInput_Limit[0])
$cInput_1 = GUICtrlCreateInput("", 80, 20, 40, 20)
GUICtrlSetLimit($cInput_1, $aInput_Limit[1])
$cInput_2 = GUICtrlCreateInput("", 150, 20, 60, 20)
GUICtrlSetLimit($cInput_2, $aInput_Limit[2])

$cButton = GUICtrlCreateButton("OK", 75, 60, 40, 25)
GUICtrlSetState($cButton, $GUI_DISABLE)

; Register the Windows message


While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
        Case $cButton
            $sString = GUICtrlRead($cInput_0) & "-" & GUICtrlRead($cInput_1) & "-" & GUICtrlRead($cInput_2)
            MsgBox(0, "Result", $sString)

Func On_WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
    ; What code has been sent
    $iCode = BitShift($wParam, 16)
    ; And which control sent it
    $iID = BitAND($wParam, 0x0000FFFF)
    ; If it was a change to an input...
    Switch $iCode
        Case $EN_UPDATE
            ; ...then check if input is full
            If StringLen(GUICtrlRead($iID)) = $aInput_Limit[$iIndex] Then
                ; If it is, then move to the next input
                GUICtrlSetState($iID + 1, $GUI_ENABLE)
                GUICtrlSetState($iID + 1, $GUI_FOCUS)
                ; And increase the index
                $iIndex += 1
EndFunc   ;==>On_WM_COMMAND
Please ask if you have any questions. :)


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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:


ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area


Share this post

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Create New...