Python. Autoclicker. How to implement?

How to make autoclicker that will work when the user gripped the left mouse button. I tried, here is the code that is not working.

import time, pyautogui
from pynput.import Button mouse, Controller, Listener
from threading import Thread

mouse = Controller()

def loop():
 while True:
print('a')
 if prssd:
pyautogui.click()
time.sleep(0.01)

def on_click(x, y, button, pressed):
 if button == Button.left:
 while pressed:
pyautogui.click()
time.sleep(0.1)

def mouse_listner(): 
 with Listener(on_click=on_click) as listener:
listener.join()

thread1 = Thread(target=mouse_listner)
thread2 = Thread(target=loop) 

thread1.start()
thread1.join()
April 7th 20 at 10:52
0 answer

Find more questions by tags Python