m1gin 1472

Get info about a window by clicking on it:

  • xwininfo -tree

Inspect an app:

  • gsettings set org.gtk.Settings.Debug enable-inspector-keybinding true; GTK_DEBUG=interactive geany

get class name of a window by clicking on it:

xprop | grep WM_CLASS


xdotool

Send key to a background (unfocused) window:

  • win=$(xdotool search --onlyvisible --class mpv | head -1); xdotool key --clearmodifiers --window $win Ctrl+q
  • xdotool search --class vlc key space
  • xdotool key --window "$(xdotool search --class mpv)" k

Some applications (like scite) looks like needs to be activated to accept keys

xdotool windowactivate --sync $(xdotool search --name Scite | tail -1) type "text abc" && xdotool key KP_Enter Return

click mouse repeatedly by interval:

xdotool click --repeat 33 --delay 11000 1

minimize window by process id:

xdotool windowminimize `xdotool search --pid $pid | tail -1`

minimize active window:

xdotool getactivewindow windowminimize

minimize window by part of its title:

xdotool windowminimize $(xdotool search --name Geany | tail -1)

activate window and type text:

xdotool windowactivate --sync $(xdotool search --name Geany | tail -1) type "text abc" && xdotool key KP_Enter Return

paste from clipboard to another app:

xdotool windowactivate --sync $(xdotool search --name Scite | tail -1); xdotool key ctrl+v

get window id by clicking on it:

xdotool selectwindow

auto move cursor down and press hotkey:

while true; do sleep 5; xdotool key Down; sleep 0.5; xdotool key ctrl+o; done;

send key to all matched windows:

xdotool search --class firefox key --window %@ ctrl+r

Send key to specific Firefox Window:

Firefox is no needed to be active and focused:

xdotool key --window $(xdotool search --name "mbplayer - Mozilla Firefox") ctrl+r


Control Mouse Using Terminal

  • xdotool mousemove 0 0 click 1

  • xdotool mousemove 100 30
  • xdotool click 1
  • xdotool type "hello"

xvkbd - virtual keyboard for X window system

Send text to specific app. (No needed to be focused, even if the app is at background).

  • xvkbd -window scite -no-repeat -text "Hello world"
  • xvkbd -window "*scite*" -text 'abc'

Switch to scite window, type "hello world" then press Ctrl+H to open Find-Replace, type world, press tab 2 times then press Alt+A to replace all.

  • xvkbd -window scite -no-repeat -text "hello world \Ch\C world\t\t earth\Aa\A"

send key even window is in background (but not minimized):

xvkbd -window "* - CutList" -no-repeat -text "a\D9"

delay key repeation (\D9 900ms at the start then \D 100ms):

xvkbd -no-repeat -text "\D69abcdefcdse\D1xyzuppk1234567890"

delay before each char:

xvkbd -delay 1000 -text "abcd" -no-repeat

get info about focused windows and widgets:

xvkbd -debug

send key to a specific window:

xvkbd -delay 1111 -window 0x5800007 -text "b" -no-repeat

stop repeating the same key (not fully sure yet):

xvkbd -text "b\D9"

send key not using XTEST method:

xvkbd -window "python key test" -no-repeat -text "h\D9" -xsendevent

Reference:

Similar Tools: xmacro , xremote

Add to: