Quantcast
Channel: Active questions tagged ubuntu - Stack Overflow
Viewing all articles
Browse latest Browse all 6547

Mouse input not blocked when running Python code on Ubuntu using pynput library

$
0
0

I want to achieve the goal of blocking mouse signals while running the program, meaning I hope to disable the mouse through the above code. However, after executing it on Ubuntu, the mouse still functions. Could you please advise on how I can modify it to achieve the intended purpose?try.py:

from pynput import mouse# Define the mouse event handlerdef on_click(x, y, button, pressed):    # In this example, we simply block the action of the mouse button    return False  # Returning False to indicate blocking the event# Listen for mouse eventswith mouse.Listener(on_click=on_click) as listener:    # Start listening for mouse events    listener.join()# When the program exits, the listener will be automatically closed, and the mouse will resume normal operation

Why my mouse still functions when I run the above Python code on Ubuntu?

I hope to receive pointed out errors or suggestions for modifying the code, and successfully disable the mouse using Python.


Viewing all articles
Browse latest Browse all 6547

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>