pynput icon indicating copy to clipboard operation
pynput copied to clipboard

Mouse is Lagging on Listener

Open lvckydrip opened this issue 3 years ago • 1 comments

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)

lvckydrip avatar Feb 01 '22 19:02 lvckydrip

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?

moses-palmer avatar Mar 01 '22 20:03 moses-palmer