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.