我们这里有一段查找标题的代码
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 未启动,则当您进入 时,
block 。因此,再次启动后,您需要在$a
将为空else$a
中搜索并放置leafpad,以便移动它。
关于shell - xdotool : how to wait so file opens and then execute ( xdotool windowactivate --sync $a ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18303741/