Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@perfaram
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save perfaram/adce0381db3db8cdb570 to your computer and use it in GitHub Desktop.
Save perfaram/adce0381db3db8cdb570 to your computer and use it in GitHub Desktop.
(AutoIT) Creating licence key input box
#include <GUIConstantsEx.au3>
HotKeySet("{BACKSPACE}","_BackSpace")
Global $gui = GUICreate("...",600)
Global $Input = GUICtrlCreateInput("", 8, 150, 584, 35)
GUICtrlSetLimit($Input,29)
GUICtrlSetFont($Input,20)
Global $LastInput = ""
GUISetState()
Local $Temp, $LenPart = 5
While 1
If $LastInput <> GUICtrlRead($Input) Then
$LastInput = GUICtrlRead($Input)
If StringLen($LastInput) = $LenPart Then
$LastInput &= "-"
Else
$Temp = StringSplit($LastInput,"-")
If $Temp[$Temp[0]] <> "" And StringLen($Temp[$Temp[0]]) >= $LenPart And StringLen(GUICtrlRead($Input)) < 29 Then
$LastInput &= "-"
EndIf
EndIf
GUICtrlSetData($Input,$LastInput)
EndIf
$Msg = GUIGetMsg()
Switch $Msg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
Func _BackSpace()
If Not WinActive($gui) Then Return 0
If StringRight($LastInput,1) = "-" Then
Return GUICtrlSetData($Input,StringLeft($LastInput,StringLen($LastInput)-2))
Else
Return GUICtrlSetData($Input,StringLeft($LastInput,StringLen($LastInput)-1))
EndIf
EndFunc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment