模拟Ubuntu的鼠标移动 [英] Simulate mouse movement in Ubuntu
本文介绍了模拟Ubuntu的鼠标移动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问题
在找自动从使用外部脚本的命令行移动鼠标光标,模拟鼠标点击按钮。我并不想:
- 记录鼠标移动和播放(例如,xnee,xmacro)
- 瞬间鼠标从一个位置移动到另一个(例如,xdotool,Python的warp_pointer)
理想的解决方案
我想要做的是以下内容:
- 编辑一个简单的脚本文件(例如,
鼠标script.txt
)。 - 添加坐标,移动速度,延迟和按钮点击列表。例如:
(X,Y,速率)=(500,500,50)
睡眠= 5
单击左= - 运行脚本:
XSIM<鼠标script.txt
。
问
你如何自动化鼠标移动,以便它从当前位置到屏幕上的另一点转变,在一个特定的速度?例如:
xdotool鼠标移动500 500 --rate 50
的 - 50率
不 xdotool
存在
解决方案
-
xaut
为Python - 按照
README
说明 - 运行:
命令和apt-get安装痛饮x11proto-xext-dev的的libx11-dev的libxtst-dev的
CD的/ usr / local / src目录
焦油ZXF xaut-0.2.0.tar.gz
。/配置 - 编辑
的src / Makefile文件
- 更改
CFLAGS
行如下:
CFLAGS = -Wall -fPIC -fno-堆栈保护 - 运行:
使 - 复制
/usr/local/src/xaut-0.2.0/python/build/lib / *
来一个新的目录。 - 更改到新目录中。
- 复制以下脚本粘贴到
mm.py
:
进口xaut
鼠标= xaut.mouse()
延迟mouse.move_delay(100)
mouse.move(500,500) - 运行脚本:
蟒蛇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:
- Edit a simple script file (e.g.,
mouse-script.txt
). - Add a list of coordinates, movement speeds, delays, and button clicks. For example:
(x, y, rate) = (500, 500, 50) sleep = 5 click = left
- 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
.
解决方案
- Download
xaut
for Python - Follow the
README
instructions - 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
- Edit
src/Makefile
- Change the
CFLAGS
line as follows:CFLAGS = -Wall -fPIC -fno-stack-protector
- Run:
make
- Copy
/usr/local/src/xaut-0.2.0/python/build/lib/*
to a new directory. - Change to that new directory.
- Copy and paste the following script into
mm.py
:import xaut mouse = xaut.mouse() delay mouse.move_delay( 100 ) mouse.move( 500, 500 )
- Run the script:
python mm.py
这篇关于模拟Ubuntu的鼠标移动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文