Jump to content
Sign in to follow this  

Getting input char count in real time

Recommended Posts

Hi all,

Is there a way in AutoIt to count input characters are they are coming into either a GUI or InputBox? This is different than just using StringLen because that depends on the InputBox being already submitted. I want to be able to trigger an action when the input reaches X characters.


Share this post

Link to post
Share on other sites

Here's one way I do it

While 1
    $msg = GUIGetMsg()
    $name = GUICtrlRead($namebox)
    If $len > 13 Then ;if length is greater than 13
        GUICtrlSetData($namebox,StringLeft($name,13));only place first 13 characters
        ;or whatever code you want
        Case $msg = $ok
        Case $msg = $cancel



My Android cat and mouse game

We're gonna need another Timmy!

Share this post

Link to post
Share on other sites

Try this

#include <GUIConstantsEx.au3>

$_Gui = GUICreate ( "", 300, 150, 200, 150 )
$_Input1 = GUICtrlCreateInput ( "blah-blah", 50, 35, 200, 20 )
$_Button1 = GUICtrlCreateButton ( "Button1", 50, 100, 80, 20 )
GUISetState ( )

While 1
    $_Msg = GUIGetMsg ( )
    Switch $_Msg
        Case $GUI_EVENT_CLOSE
        Case $_Button1

    $_CursorInfo = GUIGetCursorInfo ( $_Gui )
    If $_CursorInfo[2] And $_CursorInfo[4] = $_Input1 Then GUICtrlSetData ( $_Input1, "" )

    $_StringLen = StringLen ( GUICtrlRead ( $_Input1 ) )
    If $_StringLen <> $_StringLenOld Then
        ConsoleWrite ( "-->-- $_StringLen : " & $_StringLen & @Crlf )
        $_StringLenOld = $_StringLen

AutoIt X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...