pynput icon indicating copy to clipboard operation
pynput copied to clipboard

Keypresses in other windows

Open d4r3devil opened this issue 4 years ago • 3 comments

Whenever any key is pressed through keyboard.press () the inputs go to the window where the script is running not the then active window. Is there some method to do this?

d4r3devil avatar Oct 25 '19 08:10 d4r3devil

That sound peculiar. On what platform is this?

My prime suspect would be Linux under Wayland; the Xwayland process simluates an X server, but only for applications launched as X clients. pynput is very limited in this scenario, as it can only interact with other X clients.

moses-palmer avatar Nov 05 '19 20:11 moses-palmer

I'm having this same issue, but on windows. I've looked into it, but have not found anything useful.

FrostWolf1 avatar Nov 11 '19 22:11 FrostWolf1

@FrostWolf1, I attempted reproducing the issue, but failed. I ran the script below from cmd.exe, and then immediately switched focus to notepad.exe.

import pynput, time

time.sleep(3)
pynput.keyboard.Controller().type('Hello world!')

The text Hello world! appeared in the document in notepad.exe.

moses-palmer avatar Nov 27 '19 21:11 moses-palmer