Last active
August 29, 2015 14:01
-
-
Save perfaram/adce0381db3db8cdb570 to your computer and use it in GitHub Desktop.
(AutoIT) Creating licence key input box
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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