Skip to content

Instantly share code, notes, and snippets.

@matheusd
Created August 31, 2017 11:09
Show Gist options
  • Save matheusd/8d372a0854ee4789046f38a1df07302e to your computer and use it in GitHub Desktop.
Save matheusd/8d372a0854ee4789046f38a1df07302e to your computer and use it in GitHub Desktop.
A bash autoclicker using xdotool (clicks automatically after moving the mouse)
#!/bin/bash
# Bash Autoclicker
# Simulates key presses automatically when the mouse is moved
# Written by matheusd.com
# License: Public
((OLDX=0))
((OLDY=0))
((LIMIT = 4 * 4))
((MOVING=0))
((STOPPEDROUNDS=0))
while true ;
do
sleep 0.05
eval $(xdotool getmouselocation --shell)
((DXDX = (OLDX - X) * (OLDX - X)))
((DYDY = (OLDY - Y) * (OLDY - Y)))
#echo $DXDX $DYDY
if (( DXDX > LIMIT )) || (( DYDY > LIMIT )) ; then
echo "moving"
((MOVING=1))
elif (( MOVING == 1 )) ; then
echo stopped moving
((MOVING=0))
((STOPPEDROUNDS=0))
elif ((STOPPEDROUNDS < 1 )) ; then
echo waiting click time
((STOPPEDROUNDS = STOPPEDROUNDS + 1))
elif ((STOPPEDROUNDS < 999)) ; then
echo click
((STOPPEDROUNDS = 1000 ))
xdotool click 1
fi
((OLDX = X))
((OLDY = Y))
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment