add autoclicker script

This commit is contained in:
Ingolf Wagner 2024-09-14 07:51:31 +07:00
parent 31d674132b
commit 9afb53585b
No known key found for this signature in database
GPG key ID: 76BF5F1928B9618B
3 changed files with 60 additions and 0 deletions

View file

@ -55,6 +55,7 @@ in
pkgs.autorandr
pkgs.polygon-art.polygon-art
pkgs.xdotool # needed for rofi-emoji
pkgs.xclicker # makes stuff much easier
];
programs.i3status-rust = {

View file

@ -27,6 +27,9 @@ with lib;
qrencode
xclicker
xdotool
];
};

View file

@ -0,0 +1,56 @@
#!/bin/bash
# Function to perform a mouse click at specific coordinates
click_at() {
local x=$1
local y=$2
xdotool mousemove "$x" "$y" click 1
}
# First click coordinates (replace with desired values)
# use xclicker to find location
FIRST_X=2198
FIRST_Y=145
# Second click coordinates (replace with desired values)
# use xclicker to find location
SECOND_X=745
SECOND_Y=912
# Number of repetitions passed as script argument
REPETITIONS=$1
# Validate that the number of repetitions is a positive integer
if ! [[ "$REPETITIONS" =~ ^[0-9]+$ ]]; then
echo "Error: Number of repetitions must be a positive integer."
exit 1
fi
# Countdown from 10
echo "Starting in..."
for (( i=10; i>0; i-- ))
do
echo "$i..."
sleep 1
done
# Repeat the clicks n times
for (( i=0; i<$REPETITIONS; i++ ))
do
# Perform first click
click_at $FIRST_X $FIRST_Y
# Wait for 5 seconds
sleep 5
# Perform second click
click_at $SECOND_X $SECOND_Y
sleep 1
click_at $SECOND_X $SECOND_Y
# Wait for 5 seconds
sleep 2
done
# Resetting the coordinates transformation matrix to default
xinput set-prop "Virtual core pointer" "Coordinate Transformation Matrix" 1 0 0 0 1 0 0 0 1