Sign in to follow this  
Followers 0
_Kurt

Checking if user pressed button X times..

7 posts in this topic

#1 ·  Posted (edited)

I basically need to know if the user pressed the button 5 times with no success. Think of it as 5 attempts to log on and no success. How do I make this 'If' statement? Do I use If, Else, EndIf? Select, Case, EndSelect?

Need some help,

Kurt

*EDIT: Spelling*

Edited by _Kurt

Awaiting Diablo III..

Share this post


Link to post
Share on other sites



I basically need to know if the user pressed the button 5 times with no success. Think of it as 5 attempts to log on and no success.

Do you mean you log on in your script, or in another program?

The way I would do it, use a timer when you first press a button, set a boolean to true, if they press the button again before the timer is say... 500ms, then it restarts and adds 1 to a variable(counter). If the counter makes it to 5, then.. do your stuff, if the timer exceeds 500 then they werent in synch (i guess)

Sry I dont have time to make a script with this though

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Global $Count = 0
While 1
   If @Error then $Count =+1
   If $Count = 5 Then MsgBox(0, "", "Error, maximum errors exceeded")
WEnd

Untested

EDIT: Darn, Rad was too fast

Edited by codemyster

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Do you mean you log on in your script, or in another program?

In my script, and could you give me a little more detail for an example please?

Thanks,

Kurt

Edited by _Kurt

Awaiting Diablo III..

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Ugh alright this is all I can give you, now I gotta go ... May need some tweaking, but it worked

#include <misc.au3>
$i = 0 ;While this is 1 its ready to start the button press thing..
Hotkeyset("x", "xpress")
$timer = TimerInit()
TimerStop($timer) ;enable the timer, and disable so it doesnt start
$presscount = 3 ;number of times to press the button

While 1
    If TimerDiff($timer) > 800 Then ;delay between successful clicking... thing
        $i = 0
        $count = 0
        TimerStop($timer)
    EndIf
WEnd

func xpress() ;lol express
    If $i = 0 Then
        $timer = TimerInit() ;starts the timer
        $i = 1 ;enables the counter
    Else
        TimerStop($timer) 
        $timer = TimerInit() ;restart the timer
        $count = $count + 1
        if $count >= $presscount Then  ;basically if you pressed the number x times
            $i = 0
            $count = 0
            TimerStop($timer)
            msgbox(0, "Done", "You pressed x " & $presscount & " times")
        EndIf
    Endif
EndFunc

Good luck

edit- added some comments maybe its more understandable. Also, if you have to press it 4 times instead of 3, then make it add 1 in the If...(here)...else...endif of the func (It doesnt add 1 when you first click)

Edited by Rad

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Thanks for the help Rad, but Codemyster's code helped me the most, and it was alot shorter too :whistle: I just made some slight modifications:

Global $Count = 0
While 1
   If $Count = 5 Then MsgBox(0, "", "Error, maximum errors exceeded")
   Select
    Case $msg = $login                                    ;If user clicks on Login Button
        If GUICtrlRead($text) = $pass Then
    ;whatever you want
        Else
            $Count = $Count + 1
        EndIf
   EndSelect
WEnd

Thanks for all your help Rad and Codemyster!!

Kurt

Edited by _Kurt

Awaiting Diablo III..

Share this post


Link to post
Share on other sites

Oh... I thought you meant pressing a button ie.. a key =(

Oh well glad its working for you :whistle:

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