python 如何按住左键单击?

How do you hold down left click with python?

我知道您可以使用 pyautogui 按住某些键,但是有没有办法通过 keyDown 和 keyUp(或其他模块)按住左键单击键?如果您有帮助,在此先感谢。

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

This是pyautogui鼠标控制功能的文档

documentation 您可以使用 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.