HoneyPoop
HoneyPoop

Reputation: 513

How do you hold down left click with python?

I know that you can hold down certain keys with pyautogui, but is there a way to hold down the left click key with keyDown and keyUp (or with another module)? Thanks in advance if you help.

Upvotes: 0

Views: 11946

Answers (2)

quamrana
quamrana

Reputation: 39354

From the documentation you can use mouseDown():

>>> pyautogui.mouseDown(); pyautogui.mouseUp()  # does the same thing as a left-button mouse click
>>> pyautogui.mouseDown(button='right')  # press the right button down
>>> pyautogui.mouseUp(button='right', x=100, y=200)  # move the mouse to 100, 200, then release the right button up.

Upvotes: 3

Heisen
Heisen

Reputation: 148

pyautogui.click()                   # Left click
pyautogui.click(button='right')     # Right click

This is the docs for the mouse control functions of pyautogui.

Upvotes: 3

Related Questions