nixos-config/scripts/bash_mouse_click.sh

56 lines
1.2 KiB
Bash
Raw Normal View History

2024-09-14 02:51:31 +02:00
#!/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 3
2024-09-14 02:51:31 +02:00
# Perform second click
click_at $SECOND_X $SECOND_Y
sleep 1
click_at $SECOND_X $SECOND_Y
# Wait for 5 seconds
sleep 1
2024-09-14 02:51:31 +02:00
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