xdotool key无法在运行终端外的其他终端生效问题求助
问题:xdotool无法向非当前gnome-terminal窗口发送按键操作
我正在编写一个bash脚本,目标是打开多个gnome-terminal窗口、运行指定程序并向这些窗口发送按键操作。目前前两步已实现,但第三步用xdotool发送按键时,发现xdotool key命令仅对运行该命令的当前终端生效,无法作用于其他终端窗口。
尝试过的操作及结果
当前终端直接执行:
执行命令:xdotool key a终端正常响应:
[uname@computer ~]$ xdotool key a a[uname@computer ~]$ a链式命令操作多终端:
打开另一个终端后,执行以下链式命令:xdotool search --class gnome-terminal key --window %@ a结果是两个终端均无任何反应。根据xdotool文档,
search命令应将找到的窗口加入WINDOW STACK,后续命令可通过%@或%N引用,但实际无效。换用xterm测试,结果一致。脚本中分步骤执行:
脚本内容:xdotool search --class gnome-terminal xdotool key --window %@ w执行脚本后输出:
[uname@computer ~]$ ./test_xdo.sh 50331649 50339261 50332317 There are no windows on the stack, Can't continue.
运行环境
[uname@computer ~]$ cat /etc/redhat-release Red Hat Enterprise Linux release 8.5 (Ootpa) [uname@computer ~]$ uname -r 4.18.0-348.20.1.el8_5.x86_64 [uname@computer ~]$ xdotool -v xdotool version 3.20200624.1
内容的提问来源于stack exchange,提问作者Adam Mills
相关产品推荐
相关产品推荐

