5

I'm new to xdotool and I have a bash script to do some automated clicks for me, but the clicks don't seem to be occurring. I think it's because I'm not selecting the window, though I'm not very confident about that assessment.

Here's what I have so far:

#!/bin/bash

for x in $(seq 1760 45 1895)
do
    for y in $(seq 760 45 985)
    do
        xdotool mousemove x y click 3
        sleep 0.1
        xdotool mousemove x y+20 click 1
        sleep 0.1

    done
done
0

1 Answer 1

6

Most importantly, a variable is called using $, and y+20 doesn't work that way. However, you don't even need to calculate that, just use mousemove_relative 0 20:

#!/bin/bash
for x in {1760..1895..45}; do
  for y in {760..985..45}; do
    xdotool mousemove --sync $x $y click 3 sleep 0.1 \
    mousemove_relative --sync 0 20 click 1 sleep 0.1
  done
done

Additional changes I made:

  • substitute the seq subshell using Brace Expansion
  • use xdotool's builtin sleep function → only call it once
  • call mousemove with the --sync option to let it wait until the mouse is actually moved
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.