xdotool key " "
F1 ... F12
Return (keyup Return)
Xdotool - Launching Terminal Apps & Keys
|Some Mouse & Window Controls|
|xdotool type " "|
|xdotool key type " "||(alternate type)|
|xdotool click "1"||(left click)|
|xdotool click "2"||(middle click)|
|xdotool click "3"||(right click)|
|xdotool mousedown "1"||(left button held down)|
|xdotool mousedown "2"||(middle button held down)|
|xdotool mousedown "3"||(right button held down)|
|xdotool mouseup "1-3"||(left-middle-right button held up|
The xdotool is a utility used from the terminal or in a script to manually perform keyboard input. The commands can also be used to manually perform actions on windows and perform mouse inputs.
The syntax for xdotool depends on the command being used. To send keystrokes to a window you use the 'key' command. The syntax is as follows: xdotool [options] [keys]. There are three options available for "options":
The [keys], which are small and cap letters and the special keys in the box on the left, specify which keys are being sent to the specified window. The keys are based on the X Keysym strings. Each of these characters can be used separately and some together. A space is placed between individual keystrokes and simultaneous keystrokes are connected with a plus (+) sign. For example, to perform a single keystroke of a SPACE and then an 'x' would be: 'space x'. When simultaneous keys are pressed, such as CTRL and 'x', the keystroke would be: 'ctrl+x'.
--window window_id - specified keys for the keystrokes are sent to the window_id application. To get window_id from window-title: xdotool search --name "window-title", or xdotool getactivewindow.
- --clearmodifiers - all modifiers are cleared, such as CAPS LOCK, NUM LOCK, shift held down, a mouse button held down, etc.
- --delay milliseconds - sets the delay between each keystroke being sent, the default is 12 ms.
Xdotool can be used in scripts to carry out commands that require typing in a terminal. For example, the spell helper ispell launches in the terminal by simply typing in ispell and clicking enter (Return) on the keyboard. The shell script ispell.sh, shown in the box on the right, put in ~/bin, made excutable and put in the menus or linked to the desktop will perform the same function with a single click. Here, xdotool key "super+t" launches the terminal (my keybinding to launch terminal), xdotool key type "ispell" types "ispell" into the terminal and xdotool key "Return" effectively strikes the enter or return key. The application inxi can be launched with a similar script with xdotool key type "inxi -F". It would appear this formula for creating shell launchers will work for just about any app launched in the terminal, which includes most linux apps. For a slightly more complicated example, see the launch script to create a shutdown button in the box on the left.
A second recipe for putting terminal apps on a menu is to use a tiny shell script tlaunch.sh shown in the first box on the right. If tlaunch.sh is stored in ~/bin, then to put ispell in menus, for example, you can also use:
exec=lxterminal -e ~/bin/tlaunch.sh "ispell"
directly in the menu's config file, or .xml file, or .desktop file.