MLGpotato
MLGpotato

Reputation: 1

Why python app won't close on mouse click?

I have recently started to learn python. I have been working on simple clicker project. There are no errors in project. It does not run noclick function. My goal is to have a keybind that shutsdown the clicker. Take a look:

def noclick():
    run = 1
    exit()

def clicker():
    while(run == 1):
        mouse.click("left")
        time.sleep(float(cap))
    mouse.on_double_click (clicker)
    mouse.on_right_click (noclick)
    cap = input("Time gaps between clicks: ")
    print("Double click to activate")

Upvotes: 0

Views: 51

Answers (2)

gurkan
gurkan

Reputation: 529

You must change run value to 1. But firstly define run value globally. After, call the click function:

run=1
clicker()

Upvotes: 0

Daweo
Daweo

Reputation: 36630

Functions bodies should be intended, so rather than

def noclick():
run = 0
exit()

you should have

def noclick():
    run = 0
    exit()

Same for clicker function.

Upvotes: 1

Related Questions