Detect Mouse Clicks; Terminate Program on Scroll Wheel Movement

25 views Asked by At

How can I have this program detect left and right mouse clicks, and have the program terminate its self when mouse scroll movement is detected? I Am unable to get this program to execute properly. How can I solve this?

from pymouse import PyMouseEvent

def fibo():
    a = 0
    yield a
    b = 1
    yield b
    while True:
        a, b = b, a + b
        yield b

class Clickonacci(PyMouseEvent):
    def __init__(self):
        PyMouseEvent.__init__(self)
        self.fibo = fibo()

    def click(self, x, y, button, press):
        if press:
            if button == 1:
                print("left QAQp")
            elif button == 2:
                print("right ouob")

    def scroll(self, x, y, vertical, horizontal):
        print("Mouse scrolled")
        self.stop() 

C = Clickonacci()
C.run()
0

There are 0 answers