Created
August 16, 2012 18:17
-
-
Save aliva/3372331 to your computer and use it in GitHub Desktop.
move mouse pointer to given position in linux
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <X11/Xlib.h> | |
#include <iostream> | |
#include <unistd.h> | |
int main(void) { | |
Display* dpy = XOpenDisplay(0); | |
int scr = XDefaultScreen(dpy); | |
Window root_window = XRootWindow(dpy, scr); | |
int height = DisplayHeight(dpy, scr); | |
int width = DisplayWidth(dpy, scr); | |
std::cout << "Screen size : " << width << "x" << height << std::endl; | |
float m = (float)height/(float)width; | |
int j; | |
for(int i=0; i<width; i++){ | |
j = m*i; | |
XWarpPointer(dpy, None, root_window, 0, 0, 0, 0, i, j); | |
XFlush(dpy); | |
usleep(50); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
build command:
g++ move-cursor-linux.cpp -o move-cursor-linux -lX11