在linux中生成鼠标,键...等事件 [英] Generating mouse,key...etc events in linux
问题描述
我正在搜索这种可能性,我发现软件测试自动化工具,如LDTP,已经可以生成像鼠标点击和键盘命中的动作。
是否还有其他API可以使用?考虑到我的团队对C语言有很好的了解,没有Linux的经验,消耗多久?
你基本上有两个选项,我可以想到:
- X11:使用XTest扩展(
XTestFakeDeviceKeyEvent
,XTestFakeRelativeMotionEvent
等。) - 模块输入。
第一个使用假的输入设备(尝试运行 xinput list在大多数(所有?)X服务器中存在的shell中的
。每个调用其中一个 XTestFake *
函数生成一个X输入消息。
第二个是内核模块允许用户应用程序创建输入设备并发送输入事件。您只需打开 / dev / uinput
设备,发送几个 ioctl
来配置它,然后直接写入
输入事件。
当然,您可以编写一个输入内核驱动程序!
I am in a project where I will need to write a simple driver that accepts input from a USB device and preforms actions on GUI according to the received msg (Like writing a usb mouse driver but with my own protocol). I am searching the possibility of this and I found software testing automation tools like LDTP that already can generate actions like mouse clicks and keyboard hits . Are there other APIs to use ? How long it will consume given that my team has good understanding of C language and no experience with Linux ?
You have basically two options, that I can think of:
- X11: Use the XTest extension (
XTestFakeDeviceKeyEvent
,XTestFakeRelativeMotionEvent
, etc.) - Module uinput.
The first one makes use of fake input devices (try running xinput list
in the shell) that are present in most (all?) X servers. Each call to one of the XTestFake*
function generates an X input message.
The second one is a kernel module that allows a user application to create input devices and send input events. You simply open the /dev/uinput
device, send a few ioctl
s to configure it, and then write
the input events directly.
And, of course, you can write an input kernel driver!
这篇关于在linux中生成鼠标,键...等事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!