2014-03-28 86 views

回答

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); 
    }