xdotool X调试工具
时间:2009-07-22 来源:fewlife
by tangke <[email protected]> 2009-06-30
前几天在和共创的工程师一起调试italc软件的时候,发现一个叫xdotool的工具,比较好用,解决我们手工进行暴力测试的麻烦,在debian下面的话,直接apt-get install xdotool就可以了,该工具对键盘/鼠标都能模拟出来,对每一个窗口都能激活,功能真的是很强大(虽然是小工具哦)
下面是官方的一个例子,大家可以看一下
# Activate firefox and paste the clipboard contents into the url bar.
wid=`xdotool search --title "Mozilla Firefox"`
xdotool windowactivate $wid
sleep 0.2
xdotool key "ctrl+j"
xdotool key "BackSpace"
xdotool key "ctrl+v"
xdotool key "Return"
比如一个简单的模拟鼠标操作
xdotool mousemove x y
xdotool click 1
上面的操作表示将鼠标移动到x,y,然后按下左键
Example: focus the firefox url bar
Code:
WID=`xdotool search "Mozilla Firefox" | head -1`
xdotool windowfocus $WID
xdotool key ctrl+l
Example: Resize all visible gnome-terminal windows
Code:
WIDS=`xdotool search --onlyvisible --name "gnome-terminal"`
for id in $WIDS; do
xdotool windowsize $id 500 500
done
参考网站:
http://www.semicomplete.com/projects/xdotool/