Sign in to follow this  
Followers 0
Matthy

testing reaction time

10 posts in this topic

Hi

i am making a script to test the reaction time of a person

to test this i had the idea to make a popup and when the popup shows they should press as fast as they can on the enter button (or an other button doenst really mind)

$time = 0

;GUICreate("My GUICtrlRead")  ; will create a dialog box that when displayed is centered
GuiCreate("Reactieman", 300, 100,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

$Button_17 = GuiCtrlCreateButton("GO", 100, 50, 100, 30)
GUISetState ()       ; will display an empty dialog box
; Run the GUI until the dialog is closed
Do  
    $msg = GUIGetMsg()
    Sleep(15)
    $time = $time + 20
    if $msg = $Button_17 then
    MsgBox(4096, "Test", $time, 10) 
    $msg = $GUI_EVENT_CLOSE
    EndIf
    
 Until $msg = $GUI_EVENT_CLOSE

i had made this (the popup fuctions isnt build in yet only the'stopwatch') but the values in seconds are not rigth after 15 seconds it has 7600 and sometimes 11430 or something this is probarly because of te time it needs to do '$msg = GUIGetMsg()' ect.

and so i was wondering if there was a way to make this work probarly and more presise. in the 1000th second or something. i was thinking about making 2 scripts 1 popup script and 1 stopwatch script but dont know if that is precise ether.

any other ideas?

Cheers

Matthy

Share this post


Link to post
Share on other sites



Try using the built in timer... it works wonders:

#include<GUIConstants.au3>
Opt("GUIOnEventMode", 1)
GuiCreate("Reactieman", 300, 100,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS), BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
$Button_17 = GuiCtrlCreateButton("GO", 100, 50, 100, 30)
GUICtrlSetOnEvent( -1, "leave" )
$label = GUICtrlCreateLabel( "", 140, 25, 100 )
GUISetState ()
$timer = TimerInit()
While WinExists(  "Reactieman" )
Sleep(10)
GUICtrlSetData( $label, Int(TimerDiff( $timer )))
WEnd
Func leave()
    MsgBox(4096, "Test", Int(TimerDiff( $timer )) & " Miliseconds", 10)
    Exit
EndFunc

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

#include <GUIConstants.au3>
Global $Pressed = 0

While 1
    Sleep(Random(1000, 5000, 1))
    $Gui = GUICreate("Reactieman", 300, 100)
    $Button = GUICtrlCreateButton("GO", 0, 0, 300, 100)
    GUISetState()
    $Timer = TimerInit()
    Do
        If GUIGetMsg() = $Button Then $Pressed = 1
    Until $Pressed = 1
    GUIDelete($Gui)
    MsgBox(4096, "Test", Round(TimerDiff($Timer), 0) & "ms", 10)
    $Pressed = 0
WEnd

I'm created that but before me danwilli gave example :P

Edited by Jex

Share this post


Link to post
Share on other sites

woooooooooooooooooooooooooooooooow :P you can say that

thx ;)

Share this post


Link to post
Share on other sites

thanx for all the help the random works fine first was trying to do it by using a much harder way

Share this post


Link to post
Share on other sites
#include <GUIConstants.au3>
Global $Pressed = 0

While 1
    Sleep(Random(1000, 5000, 1))
    $Gui = GUICreate("Reactieman", 300, 100)
    $Button = GUICtrlCreateButton("GO", 0, 0, 300, 100)
    GUISetState()
    $Timer = TimerInit()
    Do
        If GUIGetMsg() = $Button Then $Pressed = 1
    Until $Pressed = 1
    GUIDelete($Gui)
    MsgBox(4096, "Test", Round(TimerDiff($Timer), 0) & "ms", 10)
    $Pressed = 0
WEndoÝ÷ ØýÊÞj׶­në[+zgj|"X j÷Å©©ïêº^N¼ºÚ"µÍÙÐÞ
M   ][ÝÕÝ    ][ÝËÝ[
[YY ÌÍÕ[YHÈLJH  [È ][ÝÛÉ][ÝËL

Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Share this post


Link to post
Share on other sites

#include <GUIConstants.au3>
Global $Pressed = 0

While 1
    Sleep(Random(1000, 5000, 1))
    $Gui = GUICreate("Reactieman", 300, 100)
    $Button = GUICtrlCreateButton("GO", 0, 0, 300, 100)
    GUISetState()
    $Timer = TimerInit()
    Do
        If GUIGetMsg() = $Button Then $Pressed = 1
    Until $Pressed = 1
    GUIDelete($Gui)
    MsgBox(4096, "Test", Round(TimerDiff($Timer), 0) & "ms", 10)
    $Pressed = 0
WEndoÝ÷ Ù:òjëh×6MsgBox(4096, "Test", Round(TimerDiff($Timer) / 1000, 1) & "ms", 10)
That would not work... it worked fine as it was... with this change, the seconds are mislabeled as miliseconds

Share this post


Link to post
Share on other sites

i now have...

#include<GUIConstants.au3>
Opt("GUIOnEventMode", 1)
$test_var = 0

For $countvar = 0 to 20 ;Step 1
Sleep(Random(5000, 10000, 1))

GuiCreate("Reactieman", 300, 100,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS), BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
$Button_17 = GuiCtrlCreateButton("GO", 100, 50, 100, 30)
GUICtrlSetOnEvent( -1, "leave" )
$label = GUICtrlCreateLabel( "", 140, 25, 100 )
GUISetState ()
$timer = TimerInit()
While WinExists(  "Reactieman" )
Sleep(10)
GUICtrlSetData( $label, Int(TimerDiff( $timer )))
WEnd

Next

Func leave()
    $test_time = Int(TimerDiff( $timer ))
    MsgBox(4096, "Test", Int(TimerDiff( $timer )) & " Miliseconds", 10)

    $test_var = $test_var + 1
    $sMsg = 'Test' & $test_var & ': ' & $test_time & 'Ms' & @CRLF

    $file = FileOpen("Results.txt", 1)
    FileWrite($file, $sMsg)
    FileClose($file)

;Exit
EndFunc

$timer = TimerInit(0) ; gave errir

$timer = 0 ; did not do anything

and for the GUI i tried ti put in the script GUIClose($GUI) but that doesnt exits

any ideas exept for rerunning the program because that would be to bad

Cheers

Matthy

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0