鼠标移动并在C / linux X11中单击

时间:2018-04-06 21:19:12

标签: c linux x11

我需要移动指针并执行单击操作。它移动正常,但点击不起作用,任何人都可以看到我错过了什么?代码如下:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>

int main(int argc, char *argv[]){

     Display *dpy;
     Window root_window;

     dpy = XOpenDisplay(0);

     root_window = XRootWindow(dpy, 0);
     XSelectInput(dpy, root_window, KeyReleaseMask);
     XWarpPointer(dpy, None, root_window, 0, 0, 0, 0, 180, 500);

     XGrabPointer(dpy, root_window, True, ButtonPressMask, GrabModeAsync,GrabModeAsync, None, None, CurrentTime);

     XFlush(dpy);

    return 0;
  }

0 个答案:

没有答案