Code : Tout sélectionner
;~ Version d'Autoit : 3.2.12.1
;~ Auteur : Max5
;~ Programme : Reflex_01
;~ Version : 1.0
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#Include <String.au3>
#Include <Misc.au3>
Opt("GUIOnEventMode", 1)
HotKeySet("z", "Quitter")
Func Quitter()
Exit
EndFunc
$TypeForm = GUICreate("Type", 109, 128, -1, -1)
GUISetOnEvent($GUI_EVENT_CLOSE, "TypeFormClose")
$ButtonVisu = GUICtrlCreateButton("Visuel", 12, 8, 83, 33, 0)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetOnEvent($ButtonVisu, "TestVisu")
$ButtonAudit = GUICtrlCreateButton("Auditif", 12, 48, 83, 33, 0)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetOnEvent($ButtonAudit, "TestAudit")
$ButtonHighScores = GUICtrlCreateButton("Scores", 12, 88, 83, 33, 0)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetOnEvent($ButtonHighScores, "GetScores")
GUISetState(@SW_SHOW, $TypeForm)
$VisuForm = GUICreate("Test Visuel", 227, 129, -1, -1)
GUICtrlCreateLabel("Appuyez sur 'K' au changement de couleur...", 8, 8, 215, 17)
$Color = GUICtrlCreateEdit("", 8, 32, 209, 89, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_READONLY,$ES_WANTRETURN))
GUICtrlSetBkColor(-1, 0xFF0000)
GUISetState(@SW_HIDE, $VisuForm)
$AuditForm = GUICreate("Test Auditif", 210, 34, -1, -1)
$Label1 = GUICtrlCreateLabel("Appuyez sur 'D' en entendant le BEEP...", 8, 8, 194, 17)
GUISetState(@SW_HIDE, $AuditForm)
While 1
Sleep(250)
WEnd
Func TestVisu()
GUISetState(@SW_SHOW, $VisuForm)
$Attente = Random(3, 13)
Sleep($Attente * 1000)
GUICtrlSetBkColor($Color, 0x0000FF)
$TimerInit = TimerInit()
Do
Sleep(1)
Until _IsPressed(_StringToHex("K"))
$reflexTPS = TimerDiff($TimerInit)/1000
MsgBox(64, "Temps de réponse visuel", $reflexTPS & " secondes")
GUISetState(@SW_HIDE, $VisuForm)
GUICtrlSetBkColor($Color, 0xFF0000)
FileWriteLine("ScoreVisu.txt", $reflexTPS & " secondes")
EndFunc
Func TestAudit()
GUISetState(@SW_SHOW, $AuditForm)
$Attente = Random(3, 13)
Sleep($Attente * 1000)
Beep(500, 50)
$TimerInit = TimerInit()
Do
Sleep(1)
Until _IsPressed(_StringToHex("D"))
$reflexTPS = TimerDiff($TimerInit)/1000
MsgBox(64, "Temps de réponse auditive", $reflexTPS & " secondes")
GUISetState(@SW_HIDE, $AuditForm)
GUICtrlSetBkColor($Color, 0xFF0000)
FileWriteLine("ScoreAudit.txt", $reflexTPS & " secondes")
EndFunc
Func GetScores()
Local $fl_visu, $fl_audit, $somme_visu, $min_visu = 1000, $max_visu = 0, $somme_audit, $min_audit = 1000, $max_audit = 0, $i_visu, $i_audit, $ligne, $score
$fl_visu = FileOpen("ScoreVisu.txt", 0)
$i_visu = 1
$somme_visu = 0
While 1
$ligne = FileReadLine($fl_visu, $i_visu)
If StringRight($ligne, 9) <> " secondes" Then ExitLoop
$score = StringTrimRight($ligne, 9)
$somme_visu += $score
If $score < $min_visu Then $min_visu = $score
If $score > $max_visu Then $max_visu = $score
$i_visu += 1
WEnd
FileClose($fl_visu)
$fl_audit = FileOpen("ScoreAudit.txt", 0)
$i_audit = 1
$somme_audit = 0
While 1
$ligne = FileReadLine($fl_audit, $i_audit)
If StringRight($ligne, 9) <> " secondes" Then ExitLoop
$score = StringTrimRight($ligne, 9)
$somme_audit += $score
If $score < $min_audit Then $min_audit = $score
If $score > $max_audit Then $max_audit = $score
$i_audit += 1
WEnd
FileClose($fl_audit)
MsgBox(0,"Scores", "Moyenne visuelle : " & Round($somme_visu * 1000 / $i_visu, 3) & " ms" & @CRLF & "Min visuel : " & $min_visu & @CRLF & "Max visuel : " & $max_visu & @CRLF & @CRLF & "Moyenne auditive : " & Round($somme_audit * 1000 / $i_audit, 3) & " ms" & @CRLF & "Min auditif : " & $min_audit & @CRLF & "Max auditif : " & $max_audit & @CRLF & @CRLF & "Rapport visuel / auditif : " & Round(($somme_visu * $i_audit) / ($somme_audit * $i_visu), 3))
EndFunc
Func TypeFormClose()
Exit
EndFunc