Jump to content

MouseMove inconsistent speed

Recommended Posts

If I use MouseMove and set the speed to, say, 100, then it will move quickly and slow down during the traversal.

The speed is inconsistent. It starts fast and slows down. I've tested this extensively.

A. Is there a reason for this

B. Why isn't this mentioned in the documentation?

C. What's the fix?

I need non-instant mouse movement, but having it have this "feature" ruins my scripts.

Link to post
Share on other sites
  • Moderators

@square65 can you please provide a reproducer that shows the behavior you're referencing? I don't use MouseMove, as it is inherently unreliable, but with this short snippet I am seeing consistent movement:

While 1
    MouseMove(100, 200, 100)
    MouseMove(1000, 280, 100)
    MouseMove(300, 500, 100)

More importantly, what are you trying to automate that you must use MouseMove? In almost every situation, there is an easier way to accomplish what you're after.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to post
Share on other sites
MouseMove (0, 0, 0)
MouseMove (1000, 1000, 100)

Moves quickly at first and then slows down. Also when it finishes its diagonal motion, at the end it moves straight down a bit which is also odd.

I'm creating a script that will have the cursor visit every point in a 2d grid.


edit: it actually moves a little to the right and then down at the very end. Giving it  weird wobbly behavior.

Edited by square65
Link to post
Share on other sites

The "slow-down" seems to be by design.  Even at slower speeds, the mouse "eases" into place at the end.  Now, why the drop at the end instead of a more direct path...not sure if that was a design decision or oversight.  

Link to post
Share on other sites

The only way I can think of to solve this is to use a workaround  :think:
Here is one - quickly done, no error checking, etc

_MyMouseMoveAtConstantSpeed(100, 100, 1000, 700, 200)

Func _MyMouseMoveAtConstantSpeed($x0, $y0, $x1, $y1, $k)
  ; params : x start, ystart, x end, y end, speed (higher = slower)
  Local $dx = $x1-$x0, $dy = $y1-$y0, $a = ($dx=0) ? 0 : $dy/$dx
  MouseMove ($x0, $y0, 0)
  For $i = 0 to $k
    If $dx = 0 Then
       $x = $x0
       $y = $y0 + ($i*$dy)/$k
      $x = $x0 + ($i*$dx)/$k
      $y = $y0 + $a*($x-$x0)
    MouseMove ($x, $y, 1)

Sorry, forgot to mention : same issue on XP SP3

Edited by mikell
Link to post
Share on other sites

This appears to be a Windows or a driver issue rather than a MouseMove bug. I see the mouse movement the same as the OP on Win10, but I've never seen it behave like that on any other OS I've used it on. I'm running on an HP laptop, using a synaptics touch pad driver.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...