boppreh / keyboard

Hook and simulate global keyboard events on Windows and Linux.
MIT License
3.77k stars 433 forks source link

keyboard hook in windows partially stops working #58

Open Keridos opened 7 years ago

Keridos commented 7 years ago

Hi there, having a weird issue here: Once I start a fullscreen game on my Windows VM that uses synergy to broadcast mouse and keyboard to the second monitor which runs the Host Linux system, my small python script I use for push to talk has a slight issue. Normally I can use the hook to safely get the key pressed every time, no matter where the mouse is at or which window on which system is focused. The keypresses when the game has started still work on the windows vm (where the keyboard and mouse are connected at) but once I move the mouse to the other screen they stop working. This is the simple script I use (client and server, using UDP): https://gist.github.com/Keridos/28fb408df82cae3b6b259e05f666b314

boppreh commented 7 years ago

Hmm, this one is really tricky. It could be the game swallowing or manipulating events, or Windows changing the way input is handled because it's full screen, or Synergy, or the VM software, or the host Linux receiver.

I think I didn't understand the issue 100%. How are you getting events in the Windows VM when the host OS is focused? And when you say "once I move the mouse to the other screen they stop working", which screen do you mean?


Just a few tips that may make your script better:

And did you mean to use keyboard on one side, and pyautogui on the other? Did you find something wrong with this library?

Keridos commented 7 years ago

The other side is linux, and I did not yet want to run my program with root privileges. The mouse and keyboard are connected to a usb controller that is passed through to the VM via VFIO. They act as if they were physically connected to the Guest OS. The side with pyautogui is the Linux host. Also I noticed that on windows admin privileged programs in focus also block the detection of keypresses.

When I move the mouse from the guest screen to the host screen (2 monitors since VFIO gpu passthrough) via synergy is what I meant.

boppreh commented 6 years ago

Hi @Keridos

It's been almost a year and I still cannot reproduce the issue, or even understand it for that matter. The library has seen many, many improvements since then, so if you still want to give it a try, please download the master branch and report back on your results.

Since it's been so long and I don't have the tools to work on it, I'm tagging this issue as "waiting-for-feedback" before closing. But please feel free to always reopen and comment.

navchandar commented 5 years ago

I've noticed this issue is present mainly when using Citrix or Amazon Workspaces.