Simple automation with xdotool on Linux

Setup

Install xdotool on Linux

sudo apt-get install xdotool

Examples

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

Scroll

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

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@1.2.3.4 -p 1234'
xdotool key Return

sleep 0.5

xdotool type 'password'
xdotool key Return