moses-palmer / pynput

Sends virtual input commands
GNU Lesser General Public License v3.0
1.74k stars 244 forks source link

Win32 suppress after enqueue #507

Open notEvil opened 1 year ago

notEvil commented 1 year ago

This adds an option specific to win32 which introduces a new filter.

The existing filter either suppresses the event early in case of raise ..., or ignores the event and passes it on in case of return False (the comment # Suppress further propagation of the event if it is filtered is plain wrong)

The new filter suppresses events after they have been enqueued.

This allows suppression of injected events as demonstrated in https://gitlab.com/notEvil/keyboard/-/blob/a868e952787d0a779b129f9382c00d907fc16a2a/keyboard/windows/evdev/__init__.py#L32 and might solve issues like https://github.com/moses-palmer/pynput/issues/455.

Feel free to adjust names and code style

ymirv commented 1 year ago

One comment: The win32 mouse handler also derives from _util/win32.py, and so you end up with NotImplementedError in that case

notEvil commented 1 year ago

Thanks, I've adjusted the class similar to keyboard._win32.Listener.