Linux – xdotool, click and hold and move the mouse

google mapslinuxmousexdotools

I want to automate a task, I need to scroll a Google like map interface, what I essentially do normally is:

  1. Click an a spot
  2. Hold the clicking
  3. Move the mouse relatively 100 pixels left
  4. Stop holding
  5. Wait a little, return to 1

However, I tried $ xdotool click 1 mousemove_relative 0 100 but it did not help, it seems it does not hold it. What can I do to achieve this?

Best Answer

You could use xnee to record your mouse action and replay it later when needed.

There's a gui for it called gnee. I didn't have very good results with it last time i tried but that was a long time ago, things might have changed since then.

Here's what i used for the recording:

$ sleep 2 ; xmessage ready ; sleep 1 ; cnee --record --mouse --keyboard -o cnee.data

This lets you move around and prepare things before starting. Click ok when you're ready, wait 1s and do your action. Ctrl-c when you're done.

Then you can replay it with:

$cnee --replay -f cnee.data -v -e /dev/null -ns

You can even replay it faster than the original (!)

$cnee --replay --speed-percent 40  -f cnee.data -v -e /dev/null -ns

You'll probably have to edit out the end of cnee.data to get rid of what you did in between your action and the Ctrl-c.

Related Question