pynput
pynput copied to clipboard
Mouse is Lagging on Listener
My problem is that my mouse is lagging around my Monitor and have a Delay while using the code below PS: sry for bad english
Code
from pynput.mouse import Button, Controller, Listener
from threading import Thread
import time
mousecon = Controller()
pressing = False
def clicklistener():
def on_click(x, y, button, pressed):
global pressing
if button == Button.right and pressed:
if pressing:
pressing = True
else:
pressing = False
with Listener(on_click=on_click) as listener:
listener.join()
Thread(target=clicklistener).start()
while True:
while pressing:
print('test')
time.sleep(0.133)
Thank you for your report, and sorry for the late response.
When pressing
is False
, you have a busy loop:
while True:
while pressing:
time.sleep(0.133)
Do you think this could be it?