Simple automation with xdotool on Linux

Setup

Install xdotool on Linux

sh
sudo apt-get install xdotool

Examples

Move mouse

sh
# xdotool mousemove x y xdotool mousemove 100 200

Move mouse and click

sh
xdotool mousemove 1815 177 click 1

Type and key press

sh
xdotool type 'cd ~' xdotool key Return xdotool key alt+Tab

Scroll

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

Mouse drag

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

Open a new terminal and connect to ssh

sh
# 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