首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >xdotool选项的问题

xdotool选项的问题
EN

Stack Overflow用户
提问于 2020-08-21 15:36:39
回答 1查看 303关注 0票数 1

xdotool页面列出了iv试图使用的一些选项和gt错误消息。例如,xdotool --sync mousemove 100 100给出了:

代码语言:javascript
复制
xdotool: unrecognized option '--sync'
Usage: xdotool <cmd> <args>

xdotool --window <window_id> type "Hello world"给出的另一个例子是:

代码语言:javascript
复制
xdotool: unrecognized option '--window'
Usage: xdotool <cmd> <args>

xdotool version 3.20160805.1

我查看了源代码,它们都被列为有效的选项,但我认为代码做得不对.

在源文件cmd_mousemove.c中:

代码语言:javascript
复制
  int cmd_mousemove(context_t *context) {
  int ret = 0;
  char *cmd = *context->argv;
  char *window_arg = NULL;

  struct mousemove mousemove;
  mousemove.clear_modifiers = 0;
  mousemove.polar_coordinates = 0;
  mousemove.opsync = 0;
  mousemove.screen = 0;
  mousemove.x = 0;
  mousemove.y = 0;
  mousemove.step = 0;

  int c;
  typedef enum {
    opt_unused, opt_help, opt_sync, opt_clearmodifiers, opt_polar,
    opt_screen, opt_step, opt_delay, opt_window
  } optlist_t;
  static struct option longopts[] = {
    { "clearmodifiers", no_argument, NULL, opt_clearmodifiers },
    { "help", no_argument, NULL, opt_help},
    { "polar", no_argument, NULL, opt_polar },
    { "screen", required_argument, NULL, opt_screen },
    //{ "step", required_argument, NULL, opt_step },
    { "sync", no_argument, NULL, opt_sync },
    //{ "delay", required_argument, NULL, opt_delay },
    { "window", required_argument, NULL, opt_window },
    { 0, 0, 0, 0 },
  };
  static const char *usage = 
      "Usage: %s [options] <x> <y>\n"
      "-c, --clearmodifiers      - reset active modifiers (alt, etc) while typing\n"
      //"-d, --delay <MS>          - sleeptime in milliseconds between steps.\n"
      //"--step <STEP>             - pixels to move each time along path to x,y.\n" "-p, --polar               - Use polar coordinates. X as an angle, Y as distance\n"
      "--screen SCREEN           - which screen to move on, default is current screen\n"
      "--sync                    - only exit once the mouse has moved\n"
      "-w, --window <windowid>   - specify a window to move relative to.\n";
  int option_index;

  while ((c = getopt_long_only(context->argc, context->argv, "+chw:pd:",
                               longopts, &option_index)) != -1) {
    switch (c) {
      case 'c':
      case opt_clearmodifiers:
        mousemove.clear_modifiers = 1;
        break;
      case 'h':
      case opt_help:
        printf(usage, cmd);
        consume_args(context, context->argc);
        return EXIT_SUCCESS;
        break;
      case opt_screen:
        mousemove.screen = atoi(optarg);
        break;
      case 'w':
      case opt_window:
        window_arg = strdup(optarg);
        break;
      case 'p':
      case opt_polar:
        mousemove.polar_coordinates = 1;
        break;
      case opt_step:
        mousemove.step = atoi(optarg);
        break;
      case 'd':
      case opt_delay:
        mousemove.delay = strtoul(optarg, NULL, 0) * 1000;
        break;
      case opt_sync:
        mousemove.opsync = 1;
        break;
      default:
        printf("unknown opt: %d\n", c);
        fprintf(stderr, usage, cmd);
        return EXIT_FAILURE;
    }
  }

阅读getopt_long_only()的手册页,我是否认为第三个论点对列出的所有选项都是不正确的?具体来说,它没有列出“s”作为选项,即使是这样,它又如何区分“同步”和“屏幕”呢?

EN

回答 1

Stack Overflow用户

发布于 2022-07-24 11:19:03

在源文件cmd_mousemove.c中:

是的,这是mousemove的一个选项,就像一个“子”-command,而不是xdotool

代码语言:javascript
复制
xdotool mousemove --sync 100 100

Xdotool有语法cmd args... -第一个命令,然后是该命令的参数。不同的命令,每个分析分开,当一个完成,下一个命令将被再次检测。这样您就可以链接命令:

代码语言:javascript
复制
xdotool mousemove --sync 100 100 type --window <windowid> "Hello world"

通常使用xdotool,首先设置“当前活动窗口”,然后对该窗口进行修改,因此是xdotool getactivewindow dosomethingxdotool search --options_to_serach dosomething。就像从文档中得到的:

代码语言:javascript
复制
xdotool search --class xterm -- windowsize --usehints %@ 80 24
        |------------------|                          ^^ - uses ative window
        cmd    args...
                                |----------------------------|
                                cmd        args...

或者:

代码语言:javascript
复制
xdotool getactivewindow windowmove 0 0

有关更多信息,请参见WINDOW STACKman xdotool中的COMMAND CHAINING部分。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63525859

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档