jordansissel / xdotool

fake keyboard/mouse input, window management, and more
Other
3.18k stars 316 forks source link

is there any way to use xdotool with window id like: 0x240008a? #79

Open piotrekkr opened 9 years ago

piotrekkr commented 9 years ago

I'm trying to send ctrl+q keystroke to thunderbird which is hidden inside systray. xdotool is not seeing thunderbird when it is inside systray (window state withdrawn) so this does not return window ID:

$ xdotool seatch --desktop 0 --class "thunderbird"

$ xprop -id 0x240008a | grep state                  
                window state: Withdrawn
                Initial state is Normal State.

It only works when there is a taskbar entry for thunderbird.

I also tried searching by PID:

$ xdotool search --any --pid 3489 --name 'not existing name'
37748737
37748842
37748879
37748880
37748881
37748894
37748912
37748919
37748922
37748925
37748928
37748935
37750322
37751934
37748874

But this does not work:

$ xdotool search --any --pid 3489 --name 'not existing name' windowactivate --sync key ctrl+q 
XGetWindowProperty[_NET_WM_DESKTOP] failed (code=1)

I'm wondering if there is some kind of option to give xdotool the window ID acquired using xwininfo? Something like:

xdotool search --id 0x3400001 

or

xdotool windowactivate --id 0x3400001

Thanks

ortango commented 8 years ago

xwininfo is giving you wids in hex format. xdotool uses decimal format. You can use printf's built in conversion to deal with this.

printf '%d\n' $xwinfo_id

richelbilderbeek commented 8 years ago

I noticed that the conversion to decimal is redundant (see a tutorial of mine (in progress))

Here is my bash function how to extract a window ID from wmctrl:

#!/bin/bash

# Get the ID of the *first* window with the arguments
# as its window title

function get_dialog_id
{
  echo `wmctrl -l | egrep "$*" | head -n 1 | cut -f 1 -d ' '`
}

I can then feed it to xdotool like:

id=`get_dialog_id "$@"`
xdotool windowactivate $id sleep 0.1 key alt+F4