Jump to content

Noob question


nodozhero
 Share

Recommended Posts

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
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...