如何从用户代码中移动鼠标光标
How to move the mouse cursor from user code?
我的数据来自arduino(它从传感器获得数据)
我想让用户程序处理数据(从/dev/ttyUSB0中读取数据后)
之后,我需要使用程序的输出来控制鼠标光标
(我现在真的不想写内核驱动程序。)
建议的方法是什么(在Linux环境中)
也许是X之上的库…或者是我可以直接将数据导入的某种工具/脚本?
取自dzone:
#include <stdio.h>
#include <stdlib.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
void mouseMove(int x, int y)
{
Display *displayMain = XOpenDisplay(NULL);
if(displayMain == NULL)
{
fprintf(stderr, "Errore nell'apertura del Display !!!n");
exit(EXIT_FAILURE);
}
XWarpPointer(displayMain, None, None, 0, 0, 0, 0, x, y);
XCloseDisplay(displayMain);
}
我知道有几个选项:
- xte是一个命令行工具:http://linux.die.net/man/1/xte
- 如果你能使用python,xaut可能更符合你的喜好:http://xautomation.sourceforge.net/index.html
或者使用node-x11:
var x = 100;
var y = 200;
require('x11').createClient(function(err, display) {
display.client.WarpPointer(0, display.screen[0].root, 0, 0, 0, 0, x, y);
});
相关文章:
- SendInput()鼠标移动计算
- Win32 发送输入鼠标移动滞后并冻结
- 如何通过拖动鼠标QT检查按钮?鼠标移动事件
- 使用具有设置延迟C++的mouse_event平滑鼠标移动
- Qt将鼠标移动事件转移到新窗口
- Wince 6.0如何在操作系统靴子后移动鼠标指针
- 鼠标单击背景窗口,而无需移动鼠标C
- 如何使用mouseevent在windows登录屏幕中移动鼠标光标
- 移动鼠标会导致事件不更新
- 按下按键或移动鼠标时,游戏速度会减慢
- 如何从用户代码中移动鼠标光标
- 如何在后台窗口中移动鼠标
- 为什么我的SDL 2应用程序中的帧速率减半,除非我在某个位置移动鼠标
- SDL 在没有焦点时不会停止移动鼠标 - SDL C++
- 只有移动鼠标后,ShowCursor才会生效
- CPP Win32移动鼠标,Wont移动到我指定的位置
- 如何在opencv中使用对象跟踪的概念移动鼠标
- 移动鼠标时抖动
- 如何知道如果我已经移动鼠标到左边或右边
- 移动鼠标位置,然后回到开始位置