Sign in to follow this  
Followers 0
nodozhero

Noob question

4 posts in this topic

Input boxes have an option for the length of input able to be typed. Is there a way to restrict the amount of input in a GuiCtrlCreateInput element, then tab to the next box, like a registration Gui for a program?

Thanks in advance.

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

This does what you're looking for (uses beta UDFs for Edit controls). It simulates a situation where a user must enter a 15-character key separated into 5-character segments, though you could easily adapt it for any key and segment size.

#include <GUIConstants.au3>
#include <GUIEdit.au3>

GuiCreate("Enter Registration Code",300,50,@DesktopWidth/2-150,@DesktopHeight/2-25)
$i1 = GuiCtrlCreateInput("",10,15,50,20)
GuiCtrlSetLimit($i1,5)
$i2 = GuiCtrlCreateInput("",70,15,50,20)
GuiCtrlSetLimit($i2,5)
$i3 = GuiCtrlCreateInput("",130,15,50,20)
GuiCtrlSetLimit($i3,5)
$b1 = GuiCtrlCreateButton("Next >",190,15,50,20)
$b2 = GuiCtrlCreateButton("Exit",250,15,40,20)
GuiSetState(@SW_SHOW)

While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE or $msg = $b2
        ExitLoop
    Case $msg = $b1
        MsgBox(0,"Next","This button gets the focus when the last input box is filled.")
    EndSelect
    If _GUICtrlEditLineLength($i1) = 5 and _GUICtrlEditGetModify($i1) > 0 Then
        GuiCtrlSetState($i2,$GUI_FOCUS)
        _GUICtrlEditSetModify($i1,false)
    EndIf
    If _GUICtrlEditLineLength($i2) = 5 and _GUICtrlEditGetModify($i2) > 0 Then
        GuiCtrlSetState($i3,$GUI_FOCUS)
        _GUICtrlEditSetModify($i2,false)
    EndIf
    If _GUICtrlEditLineLength($i3) = 5 and _GUICtrlEditGetModify($i3) > 0 Then
        GuiCtrlSetState($b1,$GUI_FOCUS)
        _GUICtrlEditSetModify($i3,false)
    EndIf
WEnd
Edited by Sokko

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Thanks. the guictrlsetlimit worked great. Another noob question, how do I get it to tab to the next inputbox after it hits the limit?

Edited by nodozhero

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  
Followers 0