m1gin 209

#xdotool #xvkbd #linux #ubuntu #automation

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"

Reference:


Examples:




Similar Tools: xmacro , xremote

Add to: