Created
January 27, 2015 19:20
-
-
Save jacobsalmela/33be93703e25a6609b6b to your computer and use it in GitHub Desktop.
April Fools to move mouse to random positions at random intervals
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Randomly moves the mouse and/or clicks | |
# | |
# Random delay (in seconds) to trigger an action | |
function random_delay() | |
{ | |
RANGE=180 | |
delayInSeconds=$RANDOM | |
let "delayInSeconds %=$RANGE" | |
echo $delayInSeconds | |
} | |
# The next two functions decide a random location to move the mouse to | |
# It is assuming a monitor has at least 1920 x 1200 resolution. | |
# Change the RANGE variable per your device if needed | |
function xCoordinate() | |
{ | |
RANGE=1920 | |
xCoord=$RANDOM | |
let "xCoord %=$RANGE" | |
echo $xCoord | |
} | |
function yCoordinate() | |
{ | |
RANGE=1200 | |
yCoord=$RANDOM | |
let "yCoord %=$RANGE" | |
echo $yCoord | |
} | |
# Creates an infinite loop | |
# Won't stop until you press Ctrl+C | |
while true | |
do | |
delay=$(random_delay) | |
echo "Sleeping for $delay..." | |
sleep $delay | |
# Get two random coordinates | |
x=$(xCoordinate) | |
y=$(yCoordinate) | |
echo "Moving mouse to $x $y..." | |
# Move based on the coordinates chosen above | |
MouseTools -x $x -y $y | |
# Uncomment the line below to click at the coordinate | |
#MouseTools -leftClick | |
# Uncomment below for the click utility | |
#click -x $x -y $y | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment