有谁能告诉我如何鼠标xwindow库移动鼠标指针。我读了一些帖子,要求我写入/ dev中可用的鼠标设备文件。但出于某种目的,我只能使用xwindow库。
答案 0 :(得分:0)
从开源项目获取此代码,将指针移动到屏幕上的(x,y)坐标。
#define SENSITIVITY 3
static void movePointerTo(int x, int y){
Bool result;
int root_x, root_y, win_x, win_y;
unsigned int mask_return;
root = DefaultRootWindow(dpy);
Window window_returned;
result = XQueryPointer(dpy, root, &window_returned, &window_returned, &root_x, &root_y, &win_x, &win_y,
&mask_return);
if (result != True) {
fprintf(stderr, "No mouse found.\n");
return;
}
XWarpPointer(dpy, None,root, 0, 0, 0, 0, root_x+(x*SENSITIVITY),root_y+(y*SENSITIVITY));
XFlush(dpy);
}