Jump to content

Delay based on MouseMove


 Share

Recommended Posts

Ok so I'm writing this bot for a game, and I have MouseMove, but I need also a delay.

The problem is, the farther the mouse moves, the smaller the delay has to be.

But if the mouse moves a small distance, the value of "Sleep" needs to be smaller.

Am I making sense?

Oh yeah, and by the way, the mouse moves on it's own, based on a PixelSearch.

Is there any way to make this possible?

Link to comment
Share on other sites

I would think you just need to come up with a formula that determines the distance from current position and the position it's going to move to, and then decide how much "speed" to set on the Mouse*() function.

Thanks,

Jarvis

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

Example to wait at least 100ms and at most 500ms.

Global $avPrevPos[2] = [0, 0], $avCurrPos[2]
Global Const $iWidth = @DesktopWidth, $iHeight = @DesktopHeight
Global Const $DiagonalScreen = Sqrt($iWidth^2+$iHeight^2)
Global $RelativeDistance

;...
;..
;.

For $i = 1 To 10
    $avCurrPos[0] = Random(0, $iWidth, 1)
    $avCurrPos[1] = Random(0, $iHeight, 1)
    
    $RelativeDistance = _Distance($avPrevPos, $avCurrPos)/$DiagonalScreen
    ConsoleWrite('-Sleep: ' & Int(100+$RelativeDistance*400) & 'ms.' & @CRLF)
    
    $avPrevPos = $avCurrPos
Next


Func _Distance($avPoint1, $avPoint2)
    Return Sqrt(($avPoint1[0]-$avPoint2[0])^2+($avPoint1[1]-$avPoint2[1])^2)
EndFunc

I hope the math is correct to fit the variable screen resolutions.

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...