Advertisement
Andrei11114

Help creating licence key input box

Apr 24th, 2013
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 1.04 KB | None | 0 0
  1. #include <GUIConstantsEx.au3>
  2.  
  3. HotKeySet("{BACKSPACE}","_BackSpace")
  4. Global $gui = GUICreate("...",600)
  5. Global $Input = GUICtrlCreateInput("", 8, 150, 584, 35)
  6.     GUICtrlSetLimit($Input,29)
  7.     GUICtrlSetFont($Input,20)
  8. Global $LastInput = ""
  9. GUISetState()
  10. Local $Temp, $LenPart = 5
  11. While 1
  12.     If $LastInput <> GUICtrlRead($Input) Then
  13.         $LastInput = GUICtrlRead($Input)
  14.         If StringLen($LastInput) = $LenPart Then
  15.             $LastInput &= "-"
  16.         Else
  17.             $Temp = StringSplit($LastInput,"-")
  18.             If $Temp[$Temp[0]] <> "" And StringLen($Temp[$Temp[0]]) >= $LenPart And StringLen(GUICtrlRead($Input)) < 29 Then
  19.                 $LastInput &= "-"
  20.             EndIf
  21.         EndIf
  22.         GUICtrlSetData($Input,$LastInput)
  23.     EndIf
  24.     $Msg = GUIGetMsg()
  25.     Switch $Msg
  26.         Case $GUI_EVENT_CLOSE
  27.             Exit
  28.  
  29.     EndSwitch
  30. WEnd
  31.  
  32. Func _BackSpace()
  33.     If Not WinActive($gui) Then Return 0
  34.     If StringRight($LastInput,1) = "-" Then
  35.         Return GUICtrlSetData($Input,StringLeft($LastInput,StringLen($LastInput)-2))
  36.     Else
  37.         Return GUICtrlSetData($Input,StringLeft($LastInput,StringLen($LastInput)-1))
  38.     EndIf
  39. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement