Browse Source

Add some randomness

master
psy 3 years ago
parent
commit
429c9f5185
  1. 33
      main.c

33
main.c

@ -1,12 +1,29 @@
#include <stdlib.h>
#include <X11/Xlib.h>
#include <time.h>
#include <stdbool.h>
void moveCursor(int destX, int destY) {
Display *dpy;
Window root_window;
dpy = XOpenDisplay(0);
root_window = XRootWindow(dpy, 0);
XWarpPointer(dpy, None, root_window, 0, 0, 0, 0, destX, destY);
XFlush(dpy);
}
int getRandom(int lower, int upper) {
unsigned int seed = (unsigned int) time(NULL);
srand(seed);
return rand() % (upper - lower + 1) + lower;
}
int main() {
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, 100, 100);
XFlush(dpy);
if (getRandom(0, 100) > 50) {
return 0;
}
moveCursor(getRandom(0, 1920), getRandom(0, 1080));
}

Loading…
Cancel
Save