Simple automation with xdotool on Linux


Install xdotool on Linux

sudo apt-get install xdotool


Move mouse

# xdotool mousemove x y
xdotool mousemove 100 200

Move mouse and click

xdotool mousemove 1815 177 click 1

Type and key press

xdotool type 'cd ~'

xdotool key Return

xdotool key alt+Tab


for i in $(seq $count); do
  # scroll up
  xdotool click 4
  # scroll down
  xdotool click 4

Mouse drag

xdotool mousemove 310 83
xdotool mousedown 1
xdotool mousemove_relative --sync 500 400
xdotool mouseup 1

Open a new terminal and connect to ssh

# open a terminal in a new window
gnome-terminal --

sleep 0.5

xdotool type 'ssh user@ -p 1234'
xdotool key Return

sleep 0.5

xdotool type 'password'
xdotool key Return