Erklärt sich von selbst.
Hier der Code:
Spoiler anzeigen
#include <GuiConstants.au3>
Opt("GuiOnEventMode", 1)
$run = False
$time = 0
$mGui = GUICreate("LogManager", 300, 100)
$label = GUICtrlCreateLabel("Mode wählen", 10, 10)
$help = GUICtrlCreateButton("?", 280, 0, 20, 20)
$easy = GUICtrlCreateButton("Easy", 40, 40)
$normal = GUICtrlCreateButton("Normal", 80, 40)
$hard = GUICtrlCreateButton("Hard", 130, 40)
$try = 0
HotKeySet("{enter}", "enter")
Global $label = GUICtrlCreateDummy()
$code = Random(1, 50, 1)
$gui = GUICreate("Log", 300, 400)
$pic = GUICtrlCreatePic("S:\Daten\Log\tk.bmp", 0, 0, 300, 400)
$input = GUICtrlCreateInput("", 20, 300, 260, 15)
$pic2 = GUICtrlCreatePic("S:\Daten\Log\licht.bmp", 20, 320, 10, 10)
$pic3 = GUICtrlCreatePic("S:\Daten\Log\licht2.bmp", 20, 320, 10, 10)
GUICtrlSetState($pic2, 32)
GUICtrlSetState($pic3, 32)
GUISetState(@SW_Show, $mGui)
GUICtrlSetOnEvent($easy, "easy")
GUICtrlSetOnEvent($normal, "normal")
GUICtrlSetOnEvent($hard, "hard")
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSE")
GUICtrlSetOnEvent($help, "help")
Func easy()
Global $mode = 1
GUISetState(@SW_Hide, $mGui)
GUISetState(@SW_Show, $gui)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSE")
Global $max_time = 20
$run = True
EndFunc
Func normal()
Global $mode = 2
GUISetState(@SW_Hide, $mGui)
GUISetState(@SW_Show, $gui)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSE")
Global $max_time = 20
$run = True
EndFunc
Func hard()
Global $mode = 3
GUISetState(@SW_Hide, $mGui)
GUISetState(@SW_Show, $gui)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSE")
Global $max_time = 5
$run = True
EndFunc
Func help()
ShellExecute("S:\Daten\Log\help.txt")
EndFunc
Func Close()
Exit
EndFunc
While 1
If $run = True Then
$time = $time + 1
$lTime = GUICtrlCreateLabel($time, 10, 10)
If $time > $max_time Then
MsgBox(0, "Log", "LogIn fehlgeschlagen")
Exit
EndIf
Sleep(1000)
EndIf
WEnd
Func enter()
$try = $try + 1
GUICtrlDelete($label)
Sleep(1)
$readout = Int(GUICtrlRead($input))
If $readout = $code Then
HotKeySet("{enter}")
MsgBox(0, "Log", "LogIn war erfolgreich")
MsgBox(0, "Log", "Du hast " & $try & " Versuche gebraucht")
;~ If FileExists("S:\Daten\Log\highscore.txt") Then
;~ $iTry = IniRead("highscore.txt", "data", "try", "")
;~ $iTime = IniRead("highscore.txt", "data", "time", "")
;~ If $iTry < $try Then
;~ MsgBox(0, "Highscore", "Neuer Highscore! Du warst " & $iTry - $try & " Versuche schneller")
;~ IniWrite("highscore.txt", "data", "time", $try)
;~ EndIf
;~ If $iTime < $time Then
;~ MsgBox(0, "Highscore", "Neuer Highscore! Du warst " & $iTime - $time & " Sekunden schneller")
;~ IniWrite("highscore.txt", "data", "time", $time)
;~ EndIf
;~ Else
;~ IniWrite("highscore.txt", "data", "time", $try)
;~ IniWrite("highscore.txt", "data", "time", $time)
;~ EndIf
Exit
EndIf
If $readout < $code Then
If $mode < 2 Then Beep(100)
If $readout < $code - 7 Then
GUICtrlSetState($pic2, 16)
GUICtrlSetState($pic3, 32)
Else
GUICtrlSetState($pic3, 16)
GUICtrlSetState($pic2, 32)
EndIf
EndIf
If $readout > $code Then
If $mode < 2 Then Beep(1000)
If $readout > $code + 7 Then
GUICtrlSetState($pic2, 16)
GUICtrlSetState($pic3, 32)
Else
GUICtrlSetState($pic3, 16)
GUICtrlSetState($pic2, 32)
EndIf
EndIf
$label = GUICtrlCreateLabel($readout, 20, 275, 260, 15)
GUICtrlSetData($input, "")
EndFunc