pawelchcki / semicomplete

Automatically exported from code.google.com/p/semicomplete
0 stars 0 forks source link

Cannot send keys to non-focussed windows anymore #85

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Open a terminal window and go to a directory named 'foo' (just that it gets 
into the window title)
2. Run 'xdotool search --name "foo" key x' in a different Terminal window

What is the expected output? What do you see instead?

There should appear an 'x' in the 'foo'-terminal window. Instead, nothing 
happens.

What version of the product are you using? On what operating system?

xdotool 2.20110530.1, Arch Linux 64bit with i3 window manager

Please provide any additional information below.

Everything worked fine until I updated my system a few days ago. And if the 
target window is the same as focused window, everything works (e.g. if the 
command would be executed in the 'foo'-terminal, an 'x' would be printed)

Original issue reported on code.google.com by kohli.al...@gmail.com on 27 May 2014 at 11:04

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
If xdotool search is indeed finding the correct window, then it is likely your 
system update included a change to your Terminal application (or a UI library) 
which now ignores X11 window events that are synthetic (originate via 
XSendEvent). The xdotool manpage explains this a bit under the 'SENDEVENT 
NOTES' section.

If this is the case (ignoring events), there isn't much we can do. You can 
sometimes monkeypatch XNextEvent to hack send_event to false, but that requires 
your application use libX11 (not libxcb or any other interface).

Sorry for this confusion.

Original comment by j...@semicomplete.com on 28 May 2014 at 2:42

GoogleCodeExporter commented 9 years ago
I thought about that, but if that would be the case, why does it work if the 
keystroke is executed on the active window? I think that is also a synthetic 
keystroke and shouldn't work either. However, if someone else runs into this 
problem, here is the script I use as a workaround:

#! /bin/bash
l=$(xdotool getactivewindow)
xdotool search "THE_NAME_OF_THE_TARGET_WINDOW" windowactivate  
xdotool key THE_KEY_YOU_WANT_TO_SEND
xdotool windowactivate $l

Original comment by kohli.al...@gmail.com on 2 Jun 2014 at 11:05

GoogleCodeExporter commented 9 years ago
EDIT: There might be a a delay needed sometimes. Add this after the second 
command:

sleep 0.1

Original comment by kohli.al...@gmail.com on 2 Jun 2014 at 11:11