purpGUI 0 Posted August 1, 2011 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. Thanks. Share this post Link to post Share on other sites
kaotkbliss 146 Posted August 1, 2011 Here's one way I do it While 1 $msg = GUIGetMsg() $name = GUICtrlRead($namebox) $len=StringLen($name) 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 EndIf Select Case $msg = $ok ;stuff Case $msg = $cancel ;stuff EndSelect WEnd 010101000110100001101001011100110010000001101001011100110010000001101101011110010010000001110011011010010110011100100001My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueekWe're gonna need another Timmy! Share this post Link to post Share on other sites
wakillon 403 Posted August 1, 2011 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 ( ) $_StringLenOld=0 While 1 $_Msg = GUIGetMsg ( ) Switch $_Msg Case $GUI_EVENT_CLOSE Exit Case $_Button1 EndSwitch $_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 EndIf WEnd AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Share this post Link to post Share on other sites
purpGUI 0 Posted August 1, 2011 Thank you guys so much! They worked perfectly! Share this post Link to post Share on other sites