Sending simulated keyboard or mouse events to an X window

Submitted by ormiret on Thu, 24/06/2010 - 11:40.

Every so often I feel compelled to interact with a GUI app from the command line, either to automate something repetitive or because I want the control to come from something other than the mouse/keyboard actually connected to the computer running the app. I know there are ways to do this but I can never remember enough detail to find them quickly so I'm making a note here in the hopes I can find it quickly next time I decide that keyboard events need scripting.

The tool to do this is xvkbd with something along the lines of:

xvkbd -text "[keys you want to send]" 

There are a few options for sending keys that aren't letters; the most generic is the \[key_sym] option.

xvkbd sends to whatever window has focus by default, for one off things it's easiest to stick in a delay and pick the window manually but for automated stuff the window will either need to be focused from the script or xvkbd told to send stuff to some other window.

( categories: )