Ejemplo n.º 1
0
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);
}
Ejemplo n.º 3
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 **) */
Ejemplo n.º 4
0
XdoInjector::~XdoInjector()
{
    xdo_free(xdo);
}
Ejemplo n.º 5
0
XDO::~XDO() {
  xdo_free(xdo_);
}