xdotool页面列出了iv试图使用的一些选项和gt错误消息。例如,xdotool --sync mousemove 100 100给出了:
xdotool: unrecognized option '--sync'
Usage: xdotool <cmd> <args>xdotool --window <window_id> type "Hello world"给出的另一个例子是:
xdotool: unrecognized option '--window'
Usage: xdotool <cmd> <args>
xdotool version 3.20160805.1我查看了源代码,它们都被列为有效的选项,但我认为代码做得不对.
在源文件cmd_mousemove.c中:
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”作为选项,即使是这样,它又如何区分“同步”和“屏幕”呢?
发布于 2022-07-24 11:19:03
在源文件cmd_mousemove.c中:
是的,这是mousemove的一个选项,就像一个“子”-command,而不是xdotool。
xdotool mousemove --sync 100 100Xdotool有语法cmd args... -第一个命令,然后是该命令的参数。不同的命令,每个分析分开,当一个完成,下一个命令将被再次检测。这样您就可以链接命令:
xdotool mousemove --sync 100 100 type --window <windowid> "Hello world"通常使用xdotool,首先设置“当前活动窗口”,然后对该窗口进行修改,因此是xdotool getactivewindow dosomething或xdotool search --options_to_serach dosomething。就像从文档中得到的:
xdotool search --class xterm -- windowsize --usehints %@ 80 24
|------------------| ^^ - uses ative window
cmd args...
|----------------------------|
cmd args...或者:
xdotool getactivewindow windowmove 0 0有关更多信息,请参见WINDOW STACK和man xdotool中的COMMAND CHAINING部分。
https://stackoverflow.com/questions/63525859
复制相似问题