moses-palmer / pynput

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

Can't suppress mouse events on macos #515

Open adamberenzweig opened 1 year ago

adamberenzweig commented 1 year ago

Maybe I'm doing it wrong, but I'm not able to suppress mouse movements on MacOS.

Here's a simple test that uses both suppress=True and a darwin_intercept handler that returns None: https://gist.github.com/adamberenzweig/bded7c07f26249fd12868c176d79a8ea

The events are logged but the OS continues to receive them and moves the mouse. Tested on MacOS 12.3.1, 12.6 and 13.0.

Thanks!

moses-palmer commented 1 year ago

Thank you for your report.

With increasing version numbers, macOS supports less and less control over mouse and keyboard from third party applications. Unfortunately, I no longer have access to any Apple devices, so I cannot test. Do you have access to older versions to check whether the functionality is still there?

lettow-humain commented 1 year ago

I wanted to use the suppress switch as well but I have the same issue as @adamberenzweig .

macos 13.0.1
pynput==1.7.6
adamberenzweig commented 9 months ago

Small update. I've been playing with this again and it is possible to suppress mouse clicks, drags, and scroll events. But plain mouse movement cannot be suppressed.

Here's a script that implements the CGEventTap directly (it doesn't use pynput at all). It successfully suppresses mouse clicks, but does not affect movement. https://gist.github.com/adamberenzweig/a5bcff3edc42297bbf7f064dc13ee43d

Tested on Ventura 13.5.2 with python 3.8.15

I'll try posting this to apple developer support...