Jump to content
Sign in to follow this  
PcExpert

Limit Characters in Input Control

Recommended Posts

PcExpert

Hi all,

How to limit the amount of characters that can be entered in an GUIctrlcreateinput() Control?

Thanks!

Share this post


Link to post
Share on other sites
PcExpert

Thanks! Does somebody know how to move the cursor to the next input when the limit is reached?

Share this post


Link to post
Share on other sites
xzaz

#include <GUIConstants.au3>

$gui = GUICreate("My GUI limit input 3 chars")  ; will create a dialog box that when displayed is centered

$input1 = GUICtrlCreateInput("", 10,20)
GUICtrlSetLimit(-1,3)   ; to limit the entry to 3 chars
$input2 = GuiCtrlCreateInput("",10,50)
                
GUISetState ()

; Run the GUI until the dialog is closed
While 1
    if StringLen(GUICtrlRead($input1)) = 3 Then
        ControlClick($gui, "", $input2)
    Endif
    $msg = GUIGetMsg()
    
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend

Maby there is a better way, but this is one way.

Edit: build some check in. so he dosn't reactivating the inputbox.

Snappie?

Edited by xzaz

Share this post


Link to post
Share on other sites
weaponx

There is an example floating around that uses an event handler. I think if you look in your AutoIt Includes folder for GUICreateIPAddress there is an example.

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.