通过写入/dev/input/mice来控制鼠标 [英] Control mouse by writing to /dev/input/mice

查看:202
本文介绍了通过写入/dev/input/mice来控制鼠标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Ubuntu 12.04.对于我的一个应用程序,我需要使用脚本在软件中控制鼠标.

I am using Ubuntu 12.04. For one of my applications I require to control the mouse in software using a script.

我知道鼠标设备是/dev/input/mice.如果我先执行cat /dev/input/mice然后移动鼠标,我会看到很多输出都转储到了屏幕上.

I understand that the mouse device is /dev/input/mice. If I do a cat /dev/input/mice and then move my mouse, I see a lot of output being dumped to the screen.

现在,我希望删除鼠标,并有一个脚本可以写入/dev/input/mice以便控制鼠标指针

Now I wish to remove the mouse, and have a script which writes to /dev/input/mice in order to control the mouse pointer

请使用以下命令帮助我:
(1)左键单击
(2)右键单击
(3)将鼠标从一个位置移动到另一位置.

Please help me with commands for the following:
(1) Perform a left click
(2) Perform a right click
(3) Move the mouse from one location to another.

请注意,我正在寻找Shell脚本解决方案,而不是C/C ++解决方案.

Kindly note that I am looking for a shell script solution, rather than a C/C++ solution.

推荐答案

这不是您提到的文件的最低要求,而是使用此工具更快的方式,而不是使该文件的转储无效.它可以在bash中完成您想要的一切.

this is not trough the file you mentioned, but its way quicker to use this tool instead of decypering the dump of that file. And it does everything you want in bash.

xdotool可以在我的终端上完成操作.
是ubuntu的打包站点. 您可能可以通过槽将其安装

xdotool does the trick in my terminal.
this is the package site for ubuntu. you probably can install it trough

# apt-get install xdotool

我可以在不添加任何存储库的情况下将其显示在gentoo上.
该工具相当简单:

I could just emerge it on gentoo without adding any repositories.
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

在这里找到它

这篇关于通过写入/dev/input/mice来控制鼠标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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