XAUT - Python library for keyboard, mouse or windows manipulation

XAUT is a Python library used to simulate keyboard and mouse use, manipulate windows and automate X11. Quintagroup uses XAUT as a part of automated web testing suite.

XAUT (formerly known as XAUTomation) is a C/Python library used to programmatically simulate keyboard and mouse use, as well as manipulate windows. XAUT controls all mouse clicks and keystrokes, including the state of caps lock, num lock, and scroll lock. Also this library automates X11. XAUT is an open source software that was inspired by AutoIt and AutoHotkey and is compatible with newer Python libraries.
Among the XAUT display functions are those that control:

  • the desktop's width;
  • the desktop's height;
  • the number of desktops currently available;
  • the current desktop.

XAUT can set a pause between key clicks, a string to type, a key to click, press, or release by id. It includes functions that turn caps lock/num lock/scroll lock on or off and return status. Also there are functions that release all resources allocated by XAUT, initialize (or reinitialize) default values, or print messages to the console.
This Python library can click the mouse, press and hold down the mouse buttons, release a previously pressed down mouse, or move the mouse to the specified coordinates. XAUT manipulates mouse be determining how long the mouse stays down when clicked and how long to pause between mouse clicks.
In context of windows manipulation XAUT has resources to:

  • retrieve the window’s current coordinates, width, height, desktop number and title/name;
  • resize window;
  • return a handle to the currently active window;
  • perform a deep search for all windows which match the name given;
  • activate the window;
  • iconify or minimize a window to the system tray, make a window full screen or restore it to its "natural" state;
  • move a window to the coordinates supplied, and potentially to a different virtual desktop.

Content that is copied/pasted or dragged/dropped is called a selection and can be managed by X11. There are two types of selections: primary and clipboard. Primary selection is activated whenever you highlight text. There is no need to make any additional actions, content is available as soon as you finished selecting. After selecting something else in any program the first selection is deleted. Clipboard selection works similar to "clipboard" in Windows OS. You can add content there using a key combination (e.g. CTRL+C), or a menu choice (e.g. Edit->Copy).
X11 in this situation does not access or store this data, but it knows who has it. When program requests that data, X11 redirects this request to the proper program. If these two programs work with the identical data types, then content pastes. The current XAUT version allows manipulations with text only. XAUT creates an invisible window that keeps data that was put into a selection. This window stays in the background and manages selection requests.
More detailed information on this Python library can be found on the XAUT website. Quintagroup uses XAUT as a part of automated web testing suite along with py.test, Selenium WebDriver, and OpenCV.