jordansissel / xdotool

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

xdotool sends 1 instead of ! #84

Open mknln opened 8 years ago

mknln commented 8 years ago

Using openbox on Ubuntu Trusty. If I do a command like:

sleep 2; for wid in `xdotool search --class QtCreator`; do xdotool key --window $wid exclam; done

...and click the window (QtCreator in this case), then the character "1" will show up in the window rather than !.

The results are mixed. I originally experienced this with a custom Qt-based browser application, but have seen these results so far: Custom browser (as noted): Shows 1 QtCreator: Shows 1 Tea (editor): Shows ! gedit: Nothing happens uxterm: Nothing happens

It seems to be due to the use of --window, as if I do xdotool key exclam on some of the windows above with the issue, it shows ! as expected.

There are other keys it happens for. I could make a list if it would be helpful.

Any ideas on root cause or workarounds? I am running the latest from git. thanks...

mknln commented 8 years ago

It looks like the shift modifier is getting stripped out. Unfortunately, sending shift+1 to send exclam also does not work.

jordansissel commented 8 years ago

I'm open to this being a bug in xdotool. When I need to debug stuff like this, I run xev and have xdotool do whatever in that window. xev is a tool that lets you see all the X11 events going to the window. If you can capture a snapshot of the events that occur when you have xdotool send keystrokes to the xev window (using --window or a chained command to send it).

(I don't have any X11 systems at present, but will in a few weeks, so I have to rely on your debugging a bit)

mknln commented 8 years ago

@jordansissel OK, I think I understand how this works now.

If you do xdotool search --class App windowfocus --sync key exclam

it will focus the window at the top of the window stack, which is not the "current window" -- well, it is to me, the user, but not to xdotool -- and thus will use XSendEvent.

It would be cool if xdotool could note that windowfocus was called and thus you probably want to treat it as the current window and use XTestFakeKeyEvent, but I don't know if that will break any other command chains or be hard to track.

mknln commented 8 years ago

BTW, I need to jump in and explain in case anyone reads this thread. I deleted a comment earlier, so this is where the thread is at:

mknln commented 8 years ago

OK, I had no reason not to try and figure it out, created pull request #85 :).