shell - xdotool : how to wait so file opens and then execute ( xdotool windowactivate --sync $a )

标签 shell terminal expect xdotool

我们这里有一段查找标题的代码

AAA

如果找到它,就会激活它,然后重新定位它。

但问题是,如果文件没有打开..它会
打开就好了。但不会激活并重新定位它。

a=`xdotool search --name "AAA"`
if [[ "$a" ]]; then
   xdotool windowactivate --sync $a
   xdotool windowmove --sync $a 377 153
  else
   leafpad '/media/1/AAA'
   xdotool windowactivate --sync $a
   xdotool windowmove --sync $a 377 153
  fi

更新

我想它不必激活它,因为它在打开时会处于事件状态,但它无法重新定位它。

最佳答案

不太确定用户遇到了什么问题,但我们开始吧:

a=`xdotool search --name "AAA"`
if [[ "$a" ]]; then
   xdotool windowactivate --sync $a
   xdotool windowmove --sync $a 377 153
else
   leafpad '/media/1/AAA'
   sleep 5
   a=`xdotool search --name "AAA"`    # <-- You need this
   xdotool windowactivate --sync $a   # <-- Otherwise $a will be empty (think about it)
   xdotool windowmove --sync $a 377 153
fi

窗口未重新定位的原因是:

您搜索“leafpad”并将其放入 $a 中,但如果 leafpad 未启动,则当您进入 时,$a 将为空else block 。因此,再次启动后,您需要在$a中搜索并放置leafpad,以便移动它。

关于shell - xdotool : how to wait so file opens and then execute ( xdotool windowactivate --sync $a ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18303741/

相关文章:

shell - 来自 bash 脚本的操作系统系统调用

用于更改目录和编译 LaTeX 源的 Java 运行时命令不起作用

linux - 为什么 vim 语法在不同终端上高亮?

linux - 用于转发端口的 Bash 脚本

linux - bash shell 脚本中的意外输出

linux - 列与制表符而不是空格对齐

windows - 未找到 cygwin make,但已安装

linux - shell脚本中的top命令

linux - 如何关闭 Expect 脚本中的 stderr 或退出后停止 "Connection to ... closed"消息?

regex - 在期望脚本中显示 cdp 邻居