Enjoy_Kovboy
Enjoy_Kovboy

Reputation: 1

How can i make something when mouse click hold down with Python

I want to make simply count the numbers automatically when mouse left click holding. I can make it on keyboard but cant on mouse.

import keyboard

a = 0
while True:
    try:
        if keyboard.is_pressed('q'):
            a += 1;
            print(a)
    except:
        break  

code view

When I press and hold it, it writes numbers on the screen by increasing it. Just i want "mouse click then holding" version of this code.

from pynput.mouse import Listener
def on_move(x, y):
    print("mouse moved")
def on_click(x, y, button, pressed):
    if pressed:
    print("mouse clicked")
def on_scroll(x, y, dx, dy):
    print("mouse scrolled")
with Listener(on_move=on_move, on_click=on_click, on_scroll=on_scroll) as listener:
    listener.join()

The above codes running perfect but just i need mouse click holding event. Or is there something like un_click event?

Upvotes: 0

Views: 77

Answers (0)

Related Questions