Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #NoTrayIcon
- Local $GUI, $Text, $Input, $Next, $StartStop, $Display, $Started = False, $RandomString, $Timer, $Time = 0
- $GUI = GUICreate("Untitled", 300, 160)
- GUISetFont(10, 1000, 0, "Courier New", $GUI)
- $Text = GUICtrlCreateLabel('Click "Start" to begin.', 20, 20, 260, 20, 0x01) ; $SS_CENTER
- $Input = GUICtrlCreateInput("", 20, 50, 260, 20)
- GUICtrlSetState($Input, 256) ; $GUI_FOCUS
- $Next = GUICtrlCreateButton("Next", 20, 80, 125, 20)
- GUICtrlSetState($Next, 512) ; $GUI_DEFBUTTON
- $StartStop = GUICtrlCreateButton("Start", 155, 80, 125, 20)
- $Display = GUICtrlCreateLabel("0.0000000000", 20, 120, 260, 20, 0x01) ; $SS_CENTER
- GUISetState(@SW_SHOW, $GUI)
- Do
- Switch GUIGetMsg()
- Case -3 ; $GUI_EVENT_CLOSE
- ExitLoop
- Case $StartStop
- If $Started Then
- GUICtrlSetData($Text, 'Click "Start" to begin.')
- GUICtrlSetData($Input, "")
- GUICtrlSetData($StartStop, "Start")
- $Started = False
- Else
- $RandomString = CreateRandomString()
- GUICtrlSetData($Input, "")
- GUICtrlSetState($Input, 256) ; $GUI_FOCUS
- GUICtrlSetData($Text, $RandomString)
- GUICtrlSetData($StartStop, "Stop")
- $Started = True
- $Timer = TimerInit()
- EndIf
- Case $Next
- If $Started And (GUICtrlRead($Input) == $RandomString) Then
- $Time += TimerDiff($Timer) / StringLen($RandomString)
- $Time /= 2
- GUICtrlSetData($Display, $Time)
- $RandomString = CreateRandomString()
- GUICtrlSetData($Input, "")
- GUICtrlSetState($Input, 256) ; $GUI_FOCUS
- GUICtrlSetData($Text, $RandomString)
- $Timer = TimerInit()
- EndIf
- EndSwitch
- Until False
- Exit
- Func CreateRandomString()
- Local $text = "", $i, $n = Random(4, 8, 1)
- For $i = 1 To $n
- Switch Random(1, 5, 1)
- Case 1, 4
- $text &= Chr(Random(Asc("A"), Asc("Z"), 1))
- Case 2, 5
- $text &= Chr(Random(Asc("a"), Asc("z"), 1))
- Case 3
- $text &= Random(0, 9, 1)
- EndSwitch
- Next
- Return $text
- EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement