Skip to content

Instantly share code, notes, and snippets.

@eirikb eirikb/
Last active Feb 21, 2020

What would you like to do?
Automated click testing in bash
function click {
scrot out.png
pos=$(findimage out.png $1)
x=$(echo $pos | grep -oP "\d+:" | grep -oP "\d+")
y=$(echo $pos | grep -oP ":\d+" | grep -oP "\d+")
size=$(file $1)
width=$(echo $size | grep -oP "\d+ x" | grep -oP "\d+")
height=$(echo $size | grep -oP "x \d+" | grep -oP "\d+")
x=$(expr $x + $width / 2)
y=$(expr $y + $height / 2)
echo "click $x $y"
xdotool mousemove $x $y click 1
click 1.png
sleep 1s
click 2.png
sleep 1s
click 3.png
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.