Controlling mouse with Python

后端 未结 15 2167
滥情空心
滥情空心 2020-11-22 14:53

How does one control the mouse cursor in Python, i.e. move it to certain position and click, under Windows?

15条回答
  •  心在旅途
    2020-11-22 15:28

    Another alternative would be mouse library, I personally use it as it is relatively simple and cross-platform.

    Here is how you can use it:

    import mouse
    # move 100 right and 100 down with a duration of 0.5 seconds
    mouse.move(100, 100, absolute=False, duration=0.5)
    # left click
    mouse.click('left')
    # right click
    mouse.click('right')
    

    Here is the source: How to Control your Mouse in Python

提交回复
热议问题