Created
November 14, 2022 19:44
-
-
Save adamberenzweig/bded7c07f26249fd12868c176d79a8ea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pynput import mouse | |
def main(): | |
def on_move(x, y): | |
print('**** on_move', x, y) | |
def _darwin_intercept(event_type, event): | |
"""For MacOS support. | |
The user must grant Accessibility access to Terminal, in the | |
Security & Privacy > Privacy system preferences. | |
""" | |
print('intercept') | |
# returning None should delete the event, to suppress OS-level event handling. | |
# https://developer.apple.com/documentation/coregraphics/cgeventtapcallback?language=objc | |
# https://pynput.readthedocs.io/en/latest/faq.html#macos | |
# FIXME but it doesn't! even with suppress=True | |
return None | |
with mouse.Listener(suppress=True, on_move=on_move, darwin_intercept=_darwin_intercept) as listener: | |
listener.join() | |
if __name__ == "__main__": | |
main() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment