Search code examples
pythonkeyboardclickpyautogui

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.


Solution

  • 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.