title: xdotool ## Random Examples ### Examples List window names matching pattern ``` xdotool search --name "$search_string" getwindowname %@ # or xdotool search --name "$search_string" | xargs -n1 xdotool getwindowname ``` Send keys to named window (sends to): ``` xdotool search --name "$search_string" key key1 key2 ... ``` ## Keysyms See XKeySyms for all. Snarfed using regex [from here](https://gitlab.com/nokun/gestures/-/wikis/xdotool-list-of-key-codes) and `/usr/include/X11/keysymdef.h`. Here is a selection. Note that these syms are case sensitive. ```csv sep=| csvhead: Keysym|Hex|Description Alt_L|0xffe9|Left alt Alt_R|0xffea|Right alt asciicircum|0x005e|U+005E CIRCUMFLEX ACCENT asciitilde|0x007e|U+007E TILDE asterisk|0x002a|U+002A ASTERISK at|0x0040|U+0040 COMMERCIAL AT BackSpace|0xff08|Back space, back char braceleft|0x007b|U+007B LEFT CURLY BRACKET braceright|0x007d|U+007D RIGHT CURLY BRACKET bracketleft|0x005b|U+005B LEFT SQUARE BRACKET bracketright|0x005d|U+005D RIGHT SQUARE BRACKET Break|0xff6b| Cancel|0xff69|Cancel, stop, abort, exit Caps_Lock|0xffe5|Caps lock Clear|0xff0b| colon|0x003a|U+003A COLON comma|0x002c|U+002C COMMA Control_L|0xffe3|Left control Control_R|0xffe4|Right control Delete|0xffff|Delete, rubout Down|0xff54|Move down, down arrow End|0xff57|EOL Escape|0xff1b| F1|0xffbe| ...|| F9|0xffc6| F10|0xffc7| F11|0xffc8| F12|0xffc9| ...|| F20|0xffd1| ...|| F30|0xffdb| ...|| F35|0xffe0| Help|0xff6a|Help Home|0xff50| Hyper_L|0xffed|Left hyper Hyper_R|0xffee|Right hyper Insert|0xff63|Insert, insert here KP_0|0xffb0| KP_1|0xffb1| ...|| KP_9|0xffb9| KP_Add|0xffab| KP_Begin|0xff9d| KP_Decimal|0xffae| KP_Delete|0xff9f| KP_Divide|0xffaf| KP_Down|0xff99| KP_End|0xff9c| KP_Enter|0xff8d|Enter KP_Equal|0xffbd|Equals KP_F1|0xff91|PF1, KP_A, ... KP_F2|0xff92| KP_F3|0xff93| KP_F4|0xff94| KP_Home|0xff95| KP_Insert|0xff9e| KP_Left|0xff96| KP_Multiply|0xffaa| KP_Next|0xff9b| KP_Page_Down|0xff9b| KP_Page_Up|0xff9a| KP_Prior|0xff9a| KP_Right|0xff98| KP_Separator|0xffac|Separator, often comma KP_Space|0xff80|Space KP_Subtract|0xffad| KP_Tab|0xff89| KP_Up|0xff97| Left|0xff51|Move left, left arrow Linefeed|0xff0a|Linefeed, LF Menu|0xff67| Meta_L|0xffe7|Left meta Meta_R|0xffe8|Right meta Multi_key|0xff20|Multi-key character compose Next|0xff56|Next Num_Lock|0xff7f| Page_Down|0xff56| Page_Up|0xff55| Pause|0xff13|Pause, hold Prior|0xff55|Prior, previous Redo|0xff66|Redo, again Return|0xff0d|Return, enter Right|0xff53|Move right, right arrow Scroll_Lock|0xff14| Select|0xff60|Select, mark semicolon|0x003b|U+003B SEMICOLON Shift_L|0xffe1|Left shift Shift_Lock|0xffe6|Shift lock Shift_R|0xffe2|Right shift slash|0x002f|U+002F SOLIDUS space|0x0020|U+0020 SPACE Super_L|0xffeb|Left super Super_R|0xffec|Right super Tab|0xff09| underscore|0x005f|U+005F LOW LINE Undo|0xff65| Up|0xff52|Move up, up arrow ``` ## Scripts Example python script using curses and subprocess to send keypresses to named window using xdotool. (Note also that there is an `xdotool` package `python-libxdo`, installable via package `python3-xdo` under Ubuntu 24.04, for python rather than using `subprocess.run`). ``` #!/usr/bin/env python3 import curses import subprocess import sys args = sys.argv[1:] try: name = args[0] except Exception: print(f"{args[0]} ") exit(1) def sendkey(x): subprocess.run(["xdotool","search","--name",name,"key",x]) def main(stdscr): curses.noecho() stdscr.addstr(f"Search for {name}\nPress left, right, up, down, or a character\n") stdscr.refresh() try: while True: c = stdscr.getch() k = chr(c) if k.upper() in "ABCDEFGHIJLKMNOPQRSTYVWXYZ0123456789": sendkey(k) elif k == " ": sendkey("space") elif c == curses.KEY_LEFT: sendkey("Left") elif c == curses.KEY_RIGHT: sendkey("Right") elif c == curses.KEY_UP: sendkey("Up") elif c == curses.KEY_DOWN: sendkey("Down") except KeyboardInterrupt: return if __name__ == "__main__": curses.wrapper(main) ```