Jump to content

Timing of keypresses


 Share

Recommended Posts

Hi mates !

First, sorry for my bad english...

Okay, my bot is now over and working fine on my computer. But I noticed it wasn't reacting the same way depending of what computer runs it.

Keypresses doesn't always last the same time.

Here is one exemple :

I've a Function like this :

Func _sleep($sleeptime)
    $timer = TimerInit()
    while TimerDiff($timer) < $sleeptime
        sleep(10)
    wend
    Return 0
EndFunc

And I do for exemple :

Func ChercherBalle()
    Send("{s down}{q down}")
    if _Sleep(3000) = 1 then Return
    Send("{s up}{q up}")
    if _Sleep(30) = 1 then Return
        
    Send("{z down}{d down}")
    if _Sleep(1950) = 1 then Return
    Send("{z up}{d up}")
    if _Sleep(30) = 1 then Return
        
    Send("{z down}")
    if _Sleep(30) = 1 then Return
    Send("{z up}")
    if _Sleep(30) = 1 then Return
    Send("{z down}")
    if _Sleep(7700) = 1 then Return
    Send("{z up}")
EndFunc

Which works great, I mean, this is the perfect timing for my computer, but not for every computers. Do you have any idea about how I can make it a lot more accurate, so it'll work the same for everybody ?

Thanks in advance for your advices ! ;)

Someone said me :

You should base the movement of the character on the time elapsed, not the other way around (we did this in the 1980s and it sucked ).

Isn't it what I'm doing ? Edited by arkane
Link to comment
Share on other sites

My bot mostly do key presses, to move from an A point to a Z point.

I can try to use do/until and use pixel detection, but it will be very hard. But I have a few ideas.

Thanks for your advice. I hope there is an another solution ? ;)

Link to comment
Share on other sites

I use do/until for window detection and it works perfect. I use the consolewrite() command inside of the do/until function for testing as well, it helps you see exactly when the program recognizes something, because it stops writing to the console at that moment

My bot mostly do key presses, to move from an A point to a Z point.

I can try to use do/until and use pixel detection, but it will be very hard. But I have a few ideas.

Thanks for your advice. I hope there is an another solution ? ;)

Link to comment
Share on other sites

try

Opt("SendKeyDelay" , 0)
Opt("SendKeyDownDelay" , 0)

Func _sleep($sleeptime)
 $timer = TimerInit()
 while TimerDiff($timer) < $sleeptime
 sleep(0)
 wend
 Return 0
EndFunc

that way you eliminate the things that might be slower on some pc's (sleep is not very accurate)

and with the Opt keys are sent instantaneously

Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...