我使用的是 Ubuntu 12.04。对于我的一个应用程序,我需要使用脚本在软件中控制鼠标。
我了解鼠标设备是/dev/input/mice
。如果我执行 cat/dev/input/mice
然后移动鼠标,我会看到很多输出被转储到屏幕上。
现在我想移除鼠标,并有一个脚本写入 /dev/input/mice
以控制鼠标指针
请帮助我执行以下命令:
(1) 执行左键单击
(2) 执行右键
(3) 将鼠标从一个位置移动到另一个位置。
请注意,我正在寻找一个 shell 脚本解决方案,而不是 C/C++ 解决方案。
最佳答案
这不是通过您提到的文件,而是使用此工具而不是解密该文件的转储的方式更快。它可以在 bash 中完成您想要的一切。
xdotool 在我的终端中解决了这个问题。
this是 ubuntu 的软件包站点。
你可能可以安装它
# apt-get install xdotool
我可以直接在 gentoo 上显示它而不添加任何存储库。
the tool works fairly simple :
#! /bin/bash
# move the mouse x y
xdotool mousemove 1800 500
# left click
xdotool click 1
# right click
xdotool click 3
关于linux - 通过写入/dev/input/mice 来控制鼠标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20595716/