Advertisement
xerpi

linux key faker

Feb 10th, 2013
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <fcntl.h>
  4. #include <errno.h>
  5. #include <termios.h>
  6. #include <unistd.h>
  7. #include <xdo.h>
  8. #include <X11/Xlib.h>
  9. #include <X11/keysym.h>
  10.  
  11. int main()
  12. {
  13.     sleep(1); //wait 1 second
  14.     printf("creating xdo...\n");
  15.     xdo_t* myXdo = xdo_new(NULL);
  16.     printf("xdo created...\n");
  17.    
  18.     printf("getting display...\n");
  19.     // Obtain the X11 display.
  20.         Display *display = XOpenDisplay(0);
  21.         if(display == NULL)
  22.         {
  23.             printf("could not open display, exiting...\n");
  24.             return -1;
  25.         }
  26.            
  27.     printf("getting root window...\n");
  28.     // Window focus
  29.         int revert;
  30.         Window winFocus;
  31.    
  32.     while(1)
  33.     {
  34.         XGetInputFocus(display, &winFocus, &revert);
  35.         xdo_keysequence_up(myXdo, winFocus, "A",  100);
  36.         xdo_keysequence_down(myXdo, winFocus, "A",  100);
  37.         usleep(1000 * 1000);
  38.     }
  39.    
  40.     printf("exiting...\n");
  41.     XCloseDisplay(display);
  42.     xdo_free(myXdo);   
  43.     return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement