Sign in to follow this  
Followers 0
Vindicator209

issues with buttons...

6 posts in this topic

#1 ·  Posted (edited)

I have a button that if you click it before it changes, you will lose, but it wont stop!, itll count you as 0 seconds anyway! can someone help me?

#include <GuiConstants.au3>
GuiCreate("GUI", 115, 52,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
$Button_1 = GuiCtrlCreateButton("<DONT CLICK>", 10, 10, 90, 30)
GuiSetState(@SW_SHOW)
GuiSetState()
$allow=0
$2=Random(5000,10000,1)
Sleep($2)
GUICtrlSetData($Button_1,"<CLICK>")
$allow=1
$time = TimerInit()
While 1
    $msg = GuiGetMsg()
    Select
        Case $msg = $Button_1
If $allow=1 Then
    MsgBox(0,"STOP!","You clicked too soon! try again!")
    Exit
EndIf
$timer = TimerDiff($time)
$seconds = Round($timer/1000,2)
            MsgBox(0,"Your Reflex time!","Your reflex time is:" & $seconds)
            If $seconds < .1 Then
                MsgBox(0,"Your Reflex time!","GREAT! You are ranked: CHAMPION")
                Exit
            EndIf
            If $seconds < .2 Then
                MsgBox(0,"Your Reflex time!","WOW... You are ranked: FAST")
                Exit
            EndIf
            If $seconds < .3 Then
                MsgBox(0,"Your Reflex time!","Wow! You are ranked: SPEEDY")
                Exit
            EndIf
            If $seconds < .4 Then
                MsgBox(0,"Your Reflex time!","Great! You are ranked: OKAY")
                Exit
            EndIf
            If $seconds < .5 Then
                MsgBox(0,"Your Reflex time!","HORRIBLE! You are ranked: S L O W")
                Exit
            EndIf
            If $seconds > .5 Then
                MsgBox(0,"Your Reflex time!","HORRIBLE! You are so slow, I wont even give you a rank!")
                Exit
            EndIf
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case Else
        ;;;
EndSelect
WEnd
Exit
Edited by MethodZero

[center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center]

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Your if statement logic seems completely off. If someone clicks it in .1 second, they'll get 5 message boxes.

If Number($seconds) < .5 And Number($seconds) > .4 Then ... is something you might look at.

Edit:

:lmao:

Had Int() instead of Number()

Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Try something like this . . .

#include <GuiConstants.au3>

Dim $seconds, $allow, $time, $timer

GuiCreate("GUI", 115, 52,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
$Button_1 = GuiCtrlCreateButton("<DONT CLICK>", 10, 10, 90, 30)
GuiSetState(@SW_SHOW)
GuiSetState()
$allow=1
$2=Random(5000,10000,1)
AdlibEnable("_EnableButton",$2)

While 1
    $msg = GuiGetMsg()
    Select
        Case $msg = $Button_1
            Switch GuiCtrlRead($Button_1)
                Case $allow=1
                    MsgBox(0,"STOP!","You clicked too soon! try again!",5)
                Case $allow = 0
                    $timer = TimerDiff($time)
                    $seconds = Round($timer/1000,2)
                    MsgBox(0,"Your Reflex time!","Your reflex time is:" & $seconds)
                    If $seconds < .1 Then
                        MsgBox(0,"Your Reflex time!","GREAT! You are ranked: CHAMPION")
                        Exit
                    EndIf
                    If $seconds < .2 Then
                        MsgBox(0,"Your Reflex time!","WOW... You are ranked: FAST")
                        Exit
                    EndIf
                    If $seconds < .3 Then
                        MsgBox(0,"Your Reflex time!","Wow! You are ranked: SPEEDY")
                        Exit
                    EndIf
                    If $seconds < .4 Then
                        MsgBox(0,"Your Reflex time!","Great! You are ranked: OKAY")
                        Exit
                    EndIf
                    If $seconds < .5 Then
                        MsgBox(0,"Your Reflex time!","HORRIBLE! You are ranked: S L O W")
                        Exit
                    EndIf
                    If $seconds > .5 Then
                        MsgBox(0,"Your Reflex time!","HORRIBLE! You are so slow, I wont even give you a rank!")
                        Exit
                    EndIf
            EndSwitch
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case Else
       ;;;
EndSelect
WEnd

Func _EnableButton()
    GUICtrlSetData($Button_1,"<CLICK>")
    $allow=0
    $time = TimerInit()
EndFunc

Using "Sleep" is not the best option here. :lmao:

Share this post


Link to post
Share on other sites

@SkiFreak, your logic is also flawed.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

@SkiFreak, your logic is also flawed.

As is my brAin... :">

I must admit to not looking too closely at the If conditions; just the fact that it did not work using "sleep".

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

are you sure? it seems his DOES work, and I twitched the script a little to test your theory on the5 boxes coming up, they dont, because I had noticedthat a while ago, and the script will actually exit itself before the other boxes come up, but thanks for bringing that up.

@SkiFreak

Thanks, both of you

I dont see how you changed the variable $allow to 0 without using anothr command..

EDIT: ok, now I see the function

Edited by MethodZero

[center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center]

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