pynput
pynput copied to clipboard
Keypresses in other windows
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?
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.
I'm having this same issue, but on windows. I've looked into it, but have not found anything useful.
@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
.