Search this site


Metadata

Articles

Projects

Presentations

xdotool - fake keyboard/mouse input, window management, and more

What is xdotool?

This tool lets you simulate keyboard input and mouse activity, move and resize windows, etc. It does this using X11's XTEST extension and other Xlib functions.

Additionally, you can search for windows and move, resize, hide, and modify window properties like the title. If your window manager supports it, you can use xdotool to switch desktops, move windows between desktops, and change the number of desktops.

Mailing list

The xdotool users mailing list is: xdotool-users@googlegroups.com

I'll be announcing new versions on this mailing list. Additionally, if you want help or want to contribute patches to xdotool, the mailing list is a good place to go.

If you want to file a bug, you can do that on my googlecode issue tracker.

Prerequisites

  • xlib (pkg-config xlib) - Standard Xlib library
  • xtst (pkg-config xtest) - XTEST library

Download

xdotool-2.20110530.1.tar.gz

Looking for older versions? Check the archive.

  • Debian and Ubuntu users can install xdotool with: apt-get install xdotool
    (Note: you will get a pretty ancient version of xdotool, if you want newer ones check here)
  • FreeBSD ports has xdotool in x11/xdotool
  • Fedora users can install xdotool: yum install xdotool
  • Mac OS X users can install xdotool using MacPorts with: sudo port install xdotool
  • OpenSUSE users can install xdotool: zypper install xdotool

Build Instructions

  1. make all install
  2. If if you want to run the test suite, use 'make test' - requires ruby and Xvfb. Will also use Xephyr, openbox, and gnome when available to run more complete tests.

If the build fails, it might be because you don't have the required libraries and header files installed. You will need to set install them, and if you don't have pkg-config for x11 and xtst, set DEFAULT_LIBS and DEFAULT_INC (see the Makefile) correctly.

If all else fails, please email the mailing list or file a bug.

How to use it

Basic usage is: xdotool <cmd> <args>

Example: focus the firefox url bar

WID=`xdotool search "Mozilla Firefox" | head -1`
xdotool windowactivate --sync $WID
xdotool key --clearmodifiers ctrl+l


# As of version 2.20100623, you can do this simpler version of above:
xdotool search "Mozilla Firefox" windowactivate --sync key --clearmodifiers ctrl+l

Example: Resize all visible gnome-terminal windows

WIDS=`xdotool search --onlyvisible --name "gnome-terminal"`
for id in $WIDS; do
  xdotool windowsize $id 500 500
done

# As of version 2.20100623, you can do this simpler version of above:
xdotool search --onlyvisible --classname "gnome-terminal" windowsize %@ 500
500