0

I'm trying to make a program that, when the left mouse button is pressed, the program automatically clicks the mouse repeatedly.

from pynput.mouse import Button, Controller, Listener
import time
import multiprocessing as mp
import keyboard

mouse = Controller()

sleepTime = 0.01

def on_click(*args):
    global clicker
    clicker = True

def Clicker():
    while clicker == True:
        mouse.click(Button.left)
        time.sleep(sleepTime)

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

if __name__ == "__main__":
    p1 = mp.Process(target=Clicker)

    p1.start()

    while True:
        if keyboard.is_pressed("å"):
            p1.kill()
            quit()

This is what I have tried but can't seem to make it work

OttoPlayZ
  • 3
  • 1

1 Answers1

0

There is a little problem in your logic.

When you left click, you trigger an on_click() that clicks the left mouse button, which triggers the on_click() function that clicks the left mouse button and so on...

You should try using a different mouse button or even keyboard keys.

How to do this?

Check this answer for similar question.