LinuxCommandLibrary

xte

TLDR

Simulate key press

$ xte 'key [Return]'
copy
Type a string
$ xte 'str [Hello World]'
copy
Click left mouse button
$ xte 'mouseclick 1'
copy
Move mouse to absolute position
$ xte 'mousemove [100] [200]'
copy
Move mouse relative
$ xte 'mousermove [10] [-5]'
copy
Simulate Ctrl+C
$ xte 'keydown Control_L' 'key c' 'keyup Control_L'
copy
Sleep between actions
$ xte 'mousemove 100 100' 'sleep 1' 'mouseclick 1'
copy

SYNOPSIS

xte [options] command [command...]

DESCRIPTION

xte generates fake keyboard and mouse input using the XTest X11 extension. It's part of the xautomation package and enables automation of GUI interactions from scripts.
Commands can be chained in a single invocation or across multiple calls. Key names follow X11 keysym naming conventions. Mouse buttons are numbered: 1 (left), 2 (middle), 3 (right), 4/5 (scroll).
Common uses include GUI testing, automating repetitive tasks, and creating macros. Often combined with xbindkeys for keyboard shortcuts.

PARAMETERS

-x display

Send commands to specified display.
-i id
Use specific XInput device.

COMMANDS

key k: Press and release key k.
keydown k: Press key k down.
keyup k: Release key k.
str text: Type text string.
mouseclick n: Click mouse button (1=left, 2=middle, 3=right).
mousedown n: Press mouse button down.
mouseup n: Release mouse button.
mousemove x y: Move to absolute position.
mousermove x y: Move relative to current position.
sleep n: Sleep n seconds.
usleep n: Sleep n microseconds.

CAVEATS

X11 only; no Wayland support. The str command has limited Unicode support. Some applications may detect synthetic input. Part of xautomation package.

HISTORY

xte is part of xautomation, a suite of tools for X11 automation created by Steve Slaven. It provides a simple command-line interface to the XTest extension, which was designed for automated testing of X applications.

SEE ALSO

xdotool(1), xbindkeys(1), xmacro(1), xinput(1)

Copied to clipboard