LinuxCommandLibrary

xdotool

TLDR

Search for windows by name

$ xdotool search --onlyvisible --name firefox
copy
Perform mouse click
$ xdotool click 1
copy
Get active window ID
$ xdotool getactivewindow
copy
Focus on specific window
$ xdotool windowfocus --sync 12345
copy
Type text with delay
$ xdotool type --delay 500 "Hello world"
copy
Press a key
$ xdotool key Return
copy
Move mouse to position
$ xdotool mousemove 100 200
copy
Get mouse location
$ xdotool getmouselocation
copy

SYNOPSIS

xdotool command [options] [args]

DESCRIPTION

xdotool simulates keyboard and mouse input in X11. It can search for windows, send keystrokes, move/click the mouse, and manipulate windows, making it useful for automation and scripting.

PARAMETERS

--delay milliseconds

Delay between keystrokes when typing
--clearmodifiers
Clear modifier keys before command
--sync
Wait for window to be visible
--onlyvisible
Search only visible windows
--name
Search by window name
--class
Search by window class
--window window_id
Target specific window

COMMANDS

search [options] pattern

Search for windows matching pattern
getactivewindow
Output currently active window ID
getwindowfocus
Output currently focused window ID
windowfocus [options] window_id
Focus a window
windowactivate [options] window_id
Activate (focus and raise) a window
windowmove [options] window_id x y
Move a window
windowsize [options] window_id width height
Resize a window
windowminimize window_id
Minimize a window
key [options] keystroke
Send a keystroke
keydown/keyup key
Press/release a key
type [options] text
Type a string of characters
click [options] button
Click mouse button (1=left, 2=middle, 3=right)
mousedown/mouseup button
Press/release mouse button
mousemove [options] x y
Move mouse cursor
getmouselocation
Get current mouse position

CAVEATS

Only works with X11, not Wayland. Some applications may not respond to synthetic input. Window IDs are session-specific and change between restarts.

HISTORY

xdotool was written by Jordan Sissel as an automation tool for X11. It provides scriptable access to the XTEST extension for simulating input events.

SEE ALSO

xte(1), xprop(1), wmctrl(1)

> TERMINAL_GEAR

Curated for the Linux community

New Raspberry Pi 3 Model B+ Board Raspberry PI 3B+

New Raspberry Pi 3 Model B+ Board Raspberry PI 3B+

$54.00
Raspberry Pi 5 8GB

Raspberry Pi 5 8GB

$134.50
GMKtec Gaming PC, K11 AMD Ryzen 9 8945HS, 32GB DDR5 RAM 1TB Mini PC Desktop Computer, Oculink, Dual NIC 2.5GbE LAN, HDMI/DisplayPort/USB4*2

GMKtec Gaming PC, K11 AMD Ryzen 9 8945HS, 32GB DDR5 RAM 1TB Mini PC Desktop Computer, Oculink, Dual NIC 2.5GbE LAN, HDMI/DisplayPort/USB4*2

$739.99
Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community

Raspberry Pi 5 8GB

Raspberry Pi 5 8GB

$134.50
BOSGAME Mini PC N95, Intel 12th Mini Computers| 16GB DDR4 RAM| 512GB M.2 2280 SSD| 4K 60HZ Triple Displays by Dual HDMI+Type-C, 6W TDP Quiet Mini PC, WIFI5, BT 5.0 Office

BOSGAME Mini PC N95, Intel 12th Mini Computers| 16GB DDR4 RAM| 512GB M.2 2280 SSD| 4K 60HZ Triple Displays by Dual HDMI+Type-C, 6W TDP Quiet Mini PC, WIFI5, BT 5.0 Office

$239.99
nuphy Air75 V2 Portable 75% Mechanical Keyboard,Wireless Keyboard

nuphy Air75 V2 Portable 75% Mechanical Keyboard,Wireless Keyboard

$129.95