Simulate mouse movement in Ubuntu

前端 未结 2 727
南旧
南旧 2021-02-04 07:22

Problem

Am looking to automatically move the mouse cursor and simulate mouse button clicks from the command-line using an external script. Am not lookin

2条回答
  •  不知归路
    2021-02-04 07:51

    on newer versions of Ubuntu (14.04+), you can use Autopilot, a UI testing tool for Ubuntu. It is made for creating and running user interface tests, but can also be used for basic GUI automation tasks.

    to install:

    $ sudo apt-get install python3-autopilot
    

    an example script (Python3) to automate mouse movement:

    #!/usr/bin/env python3
    
    from autopilot.input import Mouse
    
    mouse = Mouse.create()
    mouse.move(100, 50)
    mouse.click()
    

    You would run this just like any other Python3 script. Watch your mouse pointer move!

提交回复
热议问题