Reputation: 111
I want to creat a code in python, while the left button mouse is pressing, print Hello until the button released.
while(TheLeftMouseButtonPressing):
print('Hello')
Upvotes: 1
Views: 58
Reputation: 11
Install pynput from pip.
pip install pynput
Then you can listen to mouse clicks like this:
from pynput.mouse import Listener
def on_click(x,y,button,pressed):
print("Hello")
with Listener(on_click=on_click) as listener:
listener.join()
Upvotes: 1