Can I use xdotool as an auto-clicker?

5,042

This is my bash script for xdotool. You can set it with a keyboard shortcut. It stops when you move the mouse. Of course you can make your own script to fit your tastes.

#!/bin/bash
eval $(xdotool getmouselocation --shell)
echo $X $Y
x1=$X
y1=$Y
COUNTER=1
COUNTEND=100000
#REPEAT= 0.09s
while [ $COUNTER -lt $COUNTEND ]; do
  echo the counter is $COUNTER
  xdotool click 1
  eval $(xdotool getmouselocation --shell)
  # cancel if mouse moved
  if [ $x1 != $X ] || [ $y1 != $Y ]; then
    echo Mouse moved - script terminated
    exit 1
  fi
  #this sleep works for repetition rate
  sleep 0.01s
  let COUNTER=COUNTER+1
#  xdotool click --delay 90 --repeat 1000 1
done
Share:
5,042

Related videos on Youtube

user276059
Author by

user276059

Updated on September 18, 2022

Comments

  • user276059
    user276059 almost 2 years

    Is there a way I can use xdotool to perform a certain number of mouse clicks per second while holding down a certain key?

    • web.learner
      web.learner about 10 years
      You want xdotool to click and hold the key down or you want xdotool to click when you hold the key down?
  • David Foerster
    David Foerster over 6 years
    Not bad! I expect forking and executing 4 new processes every 10 ms would take up a considerable amount of resources and lock up the kernel in critical sections quite a bit. Can you maybe port the script to something like Python, Perl or C that uses libxdo or a similar library directly without the need to spawn new processes so frequently?
  • Evan Chen
    Evan Chen over 6 years
    Also add a xdotool keydown [key] above the while loop and xdotool keyup [key] in the if statement to hold down the key
  • Fernando D Jaime
    Fernando D Jaime almost 6 years
    hmm i have my own python app that uses xdotool but im not using libxdo.. Its quite easy to add more features to the mouse clicker but im quite busy lately so ill do it some time in the future.. github.com/FDJ-Dash/Multitool/blob/master/mouseclicker/…