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

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

问题描述

问题

在找自动从使用外部脚本的命令行移动鼠标光标,模拟鼠标点击按钮。我并不想:


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

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

理想的解决方案

我想要做的是以下内容:


  1. 编辑一个简单的脚本文件(例如,鼠标script.txt )。

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


    (X,Y,速率)=(500,500,50)
    睡眠= 5
    单击左=


  3. 运行脚本: XSIM<鼠标script.txt

你如何自动化鼠标移动,以便它从当前位置到屏幕上的另一点转变,在一个特定的速度?例如:

  xdotool鼠标移动500 500 --rate 50

- 50率 xdotool 存在


解决方案

  1. xaut 为Python

  2. 按照 README 说明

  3. 运行:


    命令和apt-get安装痛饮x11proto-xext-dev的的libx11-dev的libxtst-dev的
    CD的/ usr / local / src目录
    焦油ZXF xaut-0.2.0.tar.gz
    。/配置


  4. 编辑的src / Makefile文件

  5. 更改 CFLAGS 行如下:


    CFLAGS = -Wall -fPIC -fno-堆栈保护


  6. 运行:


    使


  7. 复制 /usr/local/src/xaut-0.2.0/python/build/lib / * 来一个新的目录。

  8. 更改到新目录中。

  9. 复制以下脚本粘贴到 mm.py


    进口xaut
    鼠标= xaut.mouse()
    延迟mouse.move_delay(100)
    mouse.move(500,500)


  10. 运行脚本:


    蟒蛇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天全站免登陆