56

I want to click on something for hours. How can I make a script or use an application so the mouse will auto-click every 5 seconds or less?

5 Answers 5

89

Edit: xdotool click --delay 5000 --repeat 200 1

For 200 clicks with mouse


Open terminal, install xdotool

sudo apt-get install xdotool

Also, open the window you want to click side by side with terminal. Select terminal (as active window) and move the mouse over the point where you want to click. In terminal type (try not to move the mouse)

xdotool getmouselocation

You will need the x:XXX and y:YYY (bottom). You can move the mouse from here, but let windows stay where they are. Type

gedit script

Paste the following on gedit (change the XXX and YYY for the numbers you got before)

#!/bin/bash
while [ 1 ]; do
  xdotool mousemove XXX YYY click 1 &
  sleep 5
done

Save and close it. Then

chmod +x script

To execute it,

./script

To get less, simply change the 5 after sleep to less.

Source: http://manpages.ubuntu.com/manpages/lucid/man1/xdotool.1.html and http://ubuntuforums.org/showthread.php?t=925217

5
  • 4
    while sleep 5; do ...
    – Olathe
    Nov 13, 2013 at 1:55
  • 3
    The 1 in click 1 means left mouse button. From the manpage: "Left mouse is 1, middle is 2, right is 3, wheel up is 4, wheel down is 5."
    – valid
    Aug 1, 2014 at 13:28
  • 9
    xdotool click --delay 5000 --repeat 100000 1 (assuming the mouse is left where it needs to click). And no need for a script for more complicated cases... while loops work on the command line... (@Olathe's method is much better as well...). while sleep 5; do xdotool mousemove XXX YYY click 1; done May 1, 2016 at 21:05
  • @GertvandenBerg Please make your comment an answer! Aug 22, 2017 at 15:32
  • (That comment is now an answer) Aug 23, 2017 at 15:41
18

I went to this page and downloaded the xautoclick_0.20-1~ppa1_amd64.deb (14.3 KiB) and it works great :D

enter image description here

Thanks to Kat Amsterdam for finding xautoclick

3
  • 10
    It is dangerous to just download a single file and install it. In order to receive security updates for the package and new features it is reccomended to install the ppa::: apt-add-repository ppa:c-korn/ppa Aug 23, 2012 at 20:45
  • This package has now been removed; see answer by @KatAmsterdam. Any ideas where to get it without being root?
    – Alex
    Jan 15, 2020 at 9:21
  • 1
    here is download page .... launchpad.net/~ferramroberto/+archive/ubuntu/extra/+build/…
    – Salem F
    Feb 20, 2020 at 2:55
8

With xdotool installed: (apt-get install xdotool (As root or with sudo))

This will click in the current mouse position every 5 seconds for 100000 times (That is somewhere between 5 and 6 days...)

xdotool click --delay 5000 --repeat 100000 1 # (assuming the mouse is left where it needs to click).

To click in a specific place: (In a command-line friendly version, for a script you probably want better formatting)

while sleep 5; do xdotool mousemove XXX YYY click 1; done

(--repeat can be used on the click here as well, but that won't repeat the move...)

3
  • Nice solution !!!
    – Eric
    Feb 1, 2018 at 8:28
  • You can even pass the cursor location as variables: eval $(xdotool getmouselocation --shell); while sleep 5; do xdotool mousemove $X $Y click 1; done
    – Paul Jones
    Feb 19, 2020 at 9:53
  • also just for fun printf 'click --delay 5000 1\n' | xargs yes | xdotool - Apr 10, 2020 at 22:52
6

In Lucid 10.04 LTS

  1. Open Ubuntu Software Center
  2. In the search box, type in autoclick
  3. Download xautoclick

    For Precise 12.04LTS the package has been removed from the Ubuntu Repositories and is only available via GetDeb.

    xautoclick instructions for install in precise

    or via Christoph Korn's PPA (who is a member of GetDeb):

    sudo apt-add-repository ppa:c-korn/ppa

  4. Download xautoclick via the software center (or if you are handy with the terminal)

    sudo apt update && sudo apt upgrade && sudo apt install xautoclick

  5. Read the instructions on xautoclick man xautoclick
  6. Under Programs, Accesories choose xautoclick
  7. Change the Interval to 5000 (the value is milliseconds)
  8. Click Start
  9. Move the mouse over what you would like to click
  10. Enjoy!

    xautoclick

To enable the GetDeb repositories:

wget -q -O - http://archive.getdeb.net/getdeb-archive.key | sudo apt-key add -
sudo sh -c 'echo "deb http://archive.getdeb.net/ubuntu precise-getdeb apps" >> /etc/apt/sources.list.d/getdeb.list'
1
  • none of those were in the software-center and i found this one archive.ubuntu.com/ubuntu/pool/universe/k/kautoclick but after installing it i get this error when trying to open it: kautoclick: error while loading shared libraries: libkdeui.so.4: cannot open shared object file: No such file or directory
    – Jeggy
    Aug 23, 2012 at 20:23
4

For even more automation you can use sikuli.

Sikuli has integrated tool that allows you to very simply write any form of interaction (mouse clicking or keyboard) by visual processing where is what on screen.

You simply select where you want your click to occur by visually selecting screen part and off it goes. Automation logic is written in python, but even if you don't have any clue about python you can easily figure it out, because tool provides you with everything right away!

You can simply install it with sudo apt-get install sikuli-ide.

Not the answer you're looking for? Browse other questions tagged or ask your own question.