jordansissel / xdotool

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

X Error of failed request: BadWindow (invalid Window parameter) #239

Closed kenorb closed 5 years ago

kenorb commented 5 years ago

I've got the following error:

++ xwininfo -id 16777217 -tree
xwininfo: Window id: 0x1000001 "XM UK MT4 Setup (32 bit)"
  Root window id: 0x1a9 (the root window) (has no name)
  Parent window id: 0x1a9 (the root window) (has no name)
     0 children.
++ xdotool key --window 16777217 --delay 500 Escape Escape Alt+f x
X Error of failed request:  BadWindow (invalid Window parameter)
  Major opcode of failed request:  25 (X_SendEvent)
  Resource id in failed request:  0x1000001
  Serial number of failed request:  20
  Current serial number in output stream:  20

Script:

while ! WID=$(xdotool search --name "MT4"); do
  winedbg --command "info wnd $WID" | grep -vw Empty | cut -c67- | xargs
  sleep 5
done
xwininfo -id $WID -tree
xdotool key --window $WID --delay 500 Escape Escape Alt+f x

The window exists as xwininfo is showing the right details.

Version: xdotool amd64 1:3.20150503.1-2 installed via Apt.

kenorb commented 5 years ago

My fault, the window closed when the installer finished. I had to improve the logic of the script.

For example:

while ! WID=$(xdotool getactivewindow); do sleep 5; done
echo "Started: $(xdotool getwindowname $WID)..." >&2