Jump to content

Automatically TAB after character limit reached


Recommended Posts

I have three input controls and I want them to accept 1 number each and tab to the next control after the number is typed.  I found a way to do it using a notification message but I'm sure that there is a cleaner way.  Please take a look and advise.

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

#AutoIt3Wrapper_Add_Constants=n

Local $hGUI = GUICreate('Tab Help')
GUICtrlCreateLabel('Input #1', 10, 20, 50, 20, $ss_centerimage)
GUICtrlCreateLabel('Input #2', 10, 40, 50, 20, $ss_centerimage)
GUICtrlCreateLabel('Input #3', 10, 60, 50, 20, $ss_centerimage)
Local $in1 = GUICtrlCreateInput('4', 70, 20, 20, 20, $es_number)
Local $in2 = GUICtrlCreateInput('4', 70, 40, 20, 20, $es_number)
Local $in3 = GUICtrlCreateInput('', 70, 60, 20, 20, $es_number)

GUISetState()

GUIRegisterMsg($WM_COMMAND, 'WM_COMMAND')

While 1
    Switch GUIGetMsg()
        Case $gui_event_close
            Exit
    EndSwitch
WEnd

Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)

    Switch BitAND($wParam, 0xFFFF)
        Case $in1, $in2, $in3
            Switch BitShift($wParam, 16)
                Case $EN_update
                    ControlSend('', '', BitAND($wParam, 0xffff), '{tab}')
            EndSwitch
    EndSwitch

    Return $GUI_RUNDEFMSG

EndFunc   ;==>WM_COMMAND

Thanks,

kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Link to comment
Share on other sites

maybe you can also try with ControlFocus, when the limit is reached

edit: this seems to work, but i cant figure out how to grasp $in1, $in2, $in3 inside the case switch, so i ended up with this messy one that seems to work, i'm interested in this feature as well ^_^

Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)

    Switch BitAND($wParam, 0xFFFF)
        Case $in1
            Switch BitShift($wParam, 16)
                Case $EN_update
                    ControlFocus('', '', $in2)
                    GuiCtrlSetState($in2, $GUI_FOCUS)
            EndSwitch
        Case $in2
            Switch BitShift($wParam, 16)
                Case $EN_update
                    ControlFocus('', '', $in3)
                    GuiCtrlSetState($in3, $GUI_FOCUS)
            EndSwitch
        Case $in3
            Switch BitShift($wParam, 16)
                Case $EN_update
                    ControlFocus('', '', $in1)
                    GuiCtrlSetState($in1, $GUI_FOCUS)
            EndSwitch
    EndSwitch

    Return $GUI_RUNDEFMSG

EndFunc   ;==>WM_COMMAND

 

Edited by jvds
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...