在Ubuntu中模拟鼠标移动 [英] Simulate mouse movement in Ubuntu

查看:773
本文介绍了在Ubuntu中模拟鼠标移动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题



我希望使用外部脚本从命令行自动移动鼠标光标和模拟鼠标按钮。不寻找:




  • 记录鼠标移动和播放(例如xnee,xmacro)

  • 立即将鼠标从一个位置移动到另一个位置(例如xdotool,Python的warp_pointer)



理想解决方案 / p>

我想做的是:


  1. 脚本文件(例如 mouse-script.txt )。

  2. 添加坐标,移动速度,延迟和按钮点击。例如:

     
    (x,y,rate)=(500,500,50)
    sleep = 5
    click = left


  3. 运行脚本: xsim<


  4. 如何自动化鼠标移动,以便以特定速度从其当前位置转换到屏幕上的另一个位置?例如:

      xdotool mousemove 500 500 --rate 50 

    - 率50 不存在与 xdotool

    解决方案


    1. 下载
    2. 按照 README c> xauttomation /rel =nofollow noreferrer 说明

    3. 执行:

       
      sudo apt-get install swig x11proto-xext-dev libx11-dev libxtst-dev
      cd / usr / local / src
      tar zxf xaut-0.2.0.tar.gz
      ./configure


    4. 编辑 src / Makefile

    5. 更改 CFLAGS

       
      CFLAGS = -Wall -fPIC -fno-stack-protector


    6. 执行:

       
      make


    7. 复制 /usr/local/src/xaut-0.2.0/python/build/ /

    8. 将以下脚本复制并粘贴到新目录中。

    9. mm.py

       
      import xaut
      mouse = xaut.mouse()
      delay mouse.move_delay )
      mouse.move(500,500)


    10. 运行脚本:

       
      python mm.py



    Problem

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

    • Record mouse movement and playback (e.g., xnee, xmacro)
    • Instantly move the mouse from one location to another (e.g., xdotool, Python's warp_pointer)

    Ideal Solution

    What I'd like to do is the following:

    1. Edit a simple script file (e.g., mouse-script.txt).
    2. Add a list of coordinates, movement speeds, delays, and button clicks. For example:

      (x, y, rate) = (500, 500, 50)
      sleep = 5
      click = left
      

    3. Run the script: xsim < mouse-script.txt.

    Question

    How do you automate mouse movement so that it transitions from its current location to another spot on the screen, at a specific velocity? For example:

    xdotool mousemove 500 500 --rate 50
    

    The --rate 50 doesn't exist with xdotool.

    解决方案

    1. Download xaut for Python
    2. Follow the README instructions
    3. Run:

      sudo apt-get install swig x11proto-xext-dev libx11-dev libxtst-dev
      cd /usr/local/src
      tar zxf xaut-0.2.0.tar.gz
      ./configure
      

    4. Edit src/Makefile
    5. Change the CFLAGS line as follows:

      CFLAGS = -Wall -fPIC -fno-stack-protector

    6. Run:

      make
      

    7. Copy /usr/local/src/xaut-0.2.0/python/build/lib/* to a new directory.
    8. Change to that new directory.
    9. Copy and paste the following script into mm.py:

      import xaut
      mouse = xaut.mouse()
      delay mouse.move_delay( 100 )
      mouse.move( 500, 500 )
      

    10. Run the script:

      python mm.py

    这篇关于在Ubuntu中模拟鼠标移动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆