Controlling mouse with Python

后端 未结 15 2377
滥情空心
滥情空心 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:19

    Another option is to use the cross-platform AutoPy package. This package has two different options for moving the mouse:

    This code snippet will instantly move the cursor to position (200,200):

    import autopy
    autopy.mouse.move(200,200)
    

    If you instead want the cursor to visibly move across the screen to a given location, you can use the smooth_move command:

    import autopy
    autopy.mouse.smooth_move(200,200)
    

提交回复
热议问题