Я хочу добиться блокировки сигналов мыши во время работы программы, то есть я надеюсь отключить мышь с помощью приведенного выше кода. Однако после выполнения в Ubuntu мышь все еще работает. Не могли бы вы посоветовать, как мне его изменить для достижения намеченной цели?
try.py:
Код: Выделить всё
from pynput import mouse
# Define the mouse event handler
def 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 events
with 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
I hope to receive pointed out errors or suggestions for modifying the code, and successfully disable the mouse using Python.
Источник: https://stackoverflow.com/questions/781 ... ut-library
Мобильная версия