Exemple #1
0
int main(int argc, char *argv[]) {
	char cmd[30];

	unsigned char *class;
	Window window_ret;

	if(argc < 2) {
		fprintf(stderr, "Missing argument\n");
		return 1;
	}

	// Get the class of the active window
	xdo_t *xdo = xdo_new(NULL);
	int ret = xdo_get_active_window(xdo, &window_ret);

	if ( ret != XDO_ERROR ) {
		xdo_get_window_property(xdo, window_ret, "WM_CLASS", &class, NULL, NULL, NULL);
	}
Exemple #2
0
int main(int argc, char **argv) {
  xdo_t *xdo = NULL;
  charcodemap_t *keys = NULL;
  int nkeys = 0;
  xdo = xdo_new(NULL);

  while (1) {
    int i = 0;
    xdo_active_modifiers_to_keycode_list(xdo, &keys, &nkeys);
    if (nkeys > 0) {
      for (i = 0; i < nkeys; i++) {
        printf("%d, ", keys[i].code);
      }
      printf("\n");
    }
    free(keys);
  }
}
void run(void)
{
    int n;

    _options._xdo=xdo_new(_options._display);
    if(_options._xdo)
    {
        while(!done())
        {
            os_work();
            if((n=udp_read(_options._socket))<0)
            {
                quit();
            }
            if(!n)
            {
                ansleep(_options._sleep);
            }
        }
        xdo_free(_options._xdo);
    }
}
void ejecutarComando(std::string &comando) {

    xdo_t * x = xdo_new(NULL);
    if (comando.substr(0, 4) == "type") {
        comando = comando.substr(5, comando.length());
        xdo_enter_text_window(x, CURRENTWINDOW, comando.data(), 0);

    } else if (comando.substr(0, 5) == "click") {
        comando = comando.substr(6, comando.length());
        int click = std::stoi(comando);
        xdo_click_window(x, CURRENTWINDOW, click);
    } else if (comando.substr(0, 9) == "mousemove") {
        comando = comando.substr(10, comando.length());
        std::vector<std::string> coordenadas = split(comando);
        int x_mouse = std::stoi(coordenadas.at(0));
        int y_mouse = std::stoi(coordenadas.at(1));
        xdo_move_mouse(x, x_mouse, y_mouse, 0);
    } else {
        xdo_send_keysequence_window(x, CURRENTWINDOW, comando.c_str(), 0);

    }
    xdo_free(x);
}
Exemple #5
0
int args_main(int argc, char **argv) {
  int ret = 0;
  int opt;
  int option_index;

  const char *usage = "Usage: %s <cmd> <args>\n";
  static struct option long_options[] = {
    { "help", no_argument, NULL, 'h' },
    { "version", no_argument, NULL, 'v' },
    { 0, 0, 0, 0 }
  };

  if (argc < 2) {
    fprintf(stderr, usage, argv[0]);
    cmd_help(NULL);
    exit(1);
  }
  
  //for(i = 0; i<argc; i++) {
    //fprintf(stderr, "argv[%d] = \"%s\"\n", i, argv[i]);
  //}

  while ((opt = getopt_long_only(argc, argv, "++hv", long_options, &option_index)) != -1) {
    switch (opt) {
      case 'h':
        cmd_help(NULL);
        exit(EXIT_SUCCESS);
      case 'v':
        cmd_version(NULL);
        exit(EXIT_SUCCESS);
      default:
        fprintf(stderr, usage, argv[0]);
        exit(EXIT_FAILURE);
    }
  }
  
  context_t context;
  context.xdo = xdo_new(NULL);
  context.prog = *argv;
  argv++; argc--;
  context.argc = argc;
  context.argv = argv;
  context.windows = NULL;
  context.nwindows = 0;
  context.have_last_mouse = False;
  context.debug = (getenv("DEBUG") != NULL);
  context.xdo->debug = context.debug;

  if (context.xdo == NULL) {
    fprintf(stderr, "Failed creating new xdo instance\n");
    return 1;
  }

  ret = context_execute(&context);

  xdo_free(context.xdo);
  if (context.windows != NULL) {
    free(context.windows);
  }

  return ret;
} /* int args_main(int, char **) */
Exemple #6
0
XdoInjector::XdoInjector()
    : width(0), height(0)
{
    xdo = xdo_new("");
    selectedWindow = None;
}
Exemple #7
0
	/**
	 * @param *str is the not constant char pointer to the string that will be printed using the kb simulation
	 * */
	int kb_print_str(char * str)
	{
		xdo_t * xdo_instance = xdo_new(NULL); ///< Create new xdo instance and null param indicates that uses env var DISPLAY, also could be used ":0.0"
		xdo_enter_text_window(xdo_instance, CURRENTWINDOW, str, 0); ///< Send a string to the current window, check xdotool ref
		return 1;///< As windows sendinput return 0 means error, we need to return the number of correct succesful insertions
	}
Exemple #8
0
XDO::XDO() :
    xdo_(xdo_new(NULL)) {
}
Exemple #9
0
int main(int argc, char* argv[]) {

  bool legacyClick = false;


  if (argc == 1) {
    std::cout << "No arguments passed.\nUSAGE: Sp2 [device ID] [-r]\n";
    exit(2);
  }
  else if (argc >= 2) 
    std::cout << "Choosing device: " << argv[1] << std::endl;
  
  if (argc == 3) {
    
    std::string arg = argv[2];


    if (arg == "-r") {
      std::cout << "Legacy right-click enabled.\n";
      legacyClick = true;
    }
    else {
      std::cout << "Unknown argument passed.\nUSAGE: Sp2 [device ID] [-r]\n";
      exit(2);
    }

  }
    
  
  
    



  int pings = 0;
  int rightClicks = 0;

  int Xpos;
  int Ypos;
  int screen;

  input keys(argv[1]); // Create input structure son

  int delay = 10000;

  xdo_t *xdo = xdo_new(NULL);

  bool sp = true;
  


  while(1) {

    keys.waitUntilChange(); //Wait until a new key is pressed (or depressed)

    
    while(keys.returnLastKey() == 64) { //While L_ALT is pressed

      if(sp) {
	xdo_click_window(xdo,CURRENTWINDOW,1);
	pings++;
	std::cout << "Ping #" << pings << "\n";
      }

      else {

	if (legacyClick == false) {

	  xdo_move_mouse(xdo,1500,950,0);
	  xdo_mouse_down(xdo,CURRENTWINDOW,1);
	  xdo_move_mouse(xdo,1920/2,1080/2,0);
	  xdo_mouse_up(xdo,CURRENTWINDOW,1);
	}
	
	else {
	  xdo_click_window(xdo,CURRENTWINDOW,2);
	}

	rightClicks++;

	if(legacyClick) 
	  std::cout << "Legacy click #" << rightClicks << std::endl;
	else
	  std::cout << "Right click #" << rightClicks << std::endl;


      }

      usleep(delay);
    }



    while(keys.returnLastKey() == 86) { //While + is pressed
      std::cout << "Delay = " << delay << std::endl;
      delay = delay + 100;
      usleep(5000);
    }



    while(keys.returnLastKey() == 82) { // While - is pressed

      if ((delay-100) >= 0) {
	std::cout << "Delay = " << delay << std::endl;
	delay = delay - 100;
      }
      else
	std::cout << "Cant have a negative delay!\n";

      usleep(5000);
    }



    if (keys.returnLastKey() == 63) {

      if(sp) {
	sp = false;
	std::cout << "Switched to KillCour.\n";
      }
      else
	std::cout << "Already switched to KillCour\n";

    }



    if (keys.returnLastKey() == 106) {

      if(sp)
	std::cout << "Already switched to SupaPing.\n";
      else {
	sp = true;
	std::cout << "Switched to SupaPing.\n";
      }
    }	

    if(keys.returnLastKey() == 84) { // NUM_5

      std::cout << "Popping Glyph!\n";

      xdo_get_mouse_location(xdo,&Xpos,&Ypos,&screen);

      xdo_move_mouse(xdo, 1885, 1000 + 80/2, screen);

      xdo_click_window(xdo,CURRENTWINDOW,1);

      xdo_move_mouse(xdo, Xpos, Ypos, screen);

    }

      


    //std::cout << keys.returnLastKey() << "\n";

    
  }
    
  return 0;
}