Simulate mouse movement in Ubuntu

Posted by Dave Jarvis on Stack Overflow See other posts from Stack Overflow or by Dave Jarvis
Published on 2010-06-06T23:03:54Z Indexed on 2010/06/06 23:12 UTC
Read the original article Hit count: 323

Filed under:
|
|
|
|

Problem

Am looking to automatically move the mouse cursor and simulate mouse button clicks from the command-line using an external script. Am not looking to:

  • Record mouse movement and playback (e.g., xnee, xmacro)
  • Instantly move the mouse from one location to another (e.g., xdotool, Python's warp_pointer)

Ideal Solution

What I'd like to do is the following:

  1. Edit a simple script file (e.g., mouse-script.txt).
  2. Add a list of coordinates, movement speeds, delays, and button clicks. For example:
    (x, y, rate) = (500, 500, 50)
    sleep = 5
    click = left
    
  3. Run the script: xsim < mouse-script.txt.

Question

How do you automate mouse movement so that it transitions from its current location to another spot on the screen, at a specific velocity? For example:

xdotool mousemove 500 500 --rate 50

The --rate 50 doesn't exist with xdotool.

I could write a script that uses xdotool to get the current mouse coordinates then move it a pixel at a time to the destination with a suitable sleep interval; what automated testing tool already does this?

Thank you.

© Stack Overflow or respective owner

Related posts about command-line

Related posts about ubuntu