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?

3 Answers 3


Pure xdotool version

Let's say your spot is 500 500

xdotool mousemove 500 500
xdotool mousedown 1
xdotool mousemove_relative 0 100
xdotool mouseup 1
sleep 1

You could also condense it to only one line, if you wanted to:

xdotool mousemove 500 500 mousedown 1 mousemove_relative 0 100 mouseup 1 sleep 1
  • 1
    The mouse movement code works, but the xdotool keydown Pointer_Button1 command doesn't do any clicks. Commented Oct 25, 2021 at 6:20
  • 2
    The command seems to have changed to: xdotool mousedown 1 (instead of Pointer_Button1)
    – desgua
    Commented Feb 8, 2022 at 14:22

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.


If you want to hold down, wait 1 second, move to coordinate 0 0, wait another second, and hold up, try this:

xdotool mousedown 1 sleep 1 mousemove 0 0 sleep 1 mouseup 1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .