Linux Command - xdotool
Mouse
xdotool click 1
#点击鼠标左键,1表示左键,2表示中键,3表示右键。
xdotool Version: 2.20110530.1
Target ARCH: x86 (i.e x86_32 and x86_64)
Using xdotool:
root@localhost:/root> xdotool
Usage: xdotool <cmd> <args>
Available commands:
getactivewindow
getwindowfocus
getwindowname
getwindowpid
getwindowgeometry
getdisplaygeometry
search
selectwindow
help
version
behave
behave_screen_edge
click
getmouselocation
key
keydown
keyup
mousedown
mousemove
mousemove_relative
mouseup
set_window
type
windowactivate
windowfocus
windowkill
windowmap
windowminimize
windowmove
windowraise
windowreparent
windowsize
windowunmap
set_num_desktops
get_num_desktops
set_desktop
get_desktop
set_desktop_for_window
get_desktop_for_window
get_desktop_viewport
set_desktop_viewport
exec
sleep
root@localhost:/root>
XPID
xdotool search --name "X Application"
Mouse
xdotool mousemove x y (x, y轴像素坐标)
#移动鼠标到(x,y)坐标
xdotool getmouselocation 2>/dev/null |awk -F ":" '{print $2,$3}' |awk '{print $1,$3}'
#获取光标的(x,y)的坐标
#获取光标的(x,y)的坐标
xdotool click 1
#点击鼠标左键,1表示左键,2表示中键,3表示右键。
Window
xdotool windowactivate $XPID
#获取鼠标的焦点在窗口PID
#获取鼠标的焦点在窗口PID
xdotool windowmove $XPID x y (x, y轴像素坐标)
#移动窗口PID到(x,y)坐标
Keyboard
例如模拟键盘在terminal输入“ls”+回车操作
xdotool key 'ctrl+c'
#按下ctrl和l键
#按下ctrl和l键
xdotool sleep 1
xdotool key 'l'
xdotool sleep 1
xdotool key '2'
xdotool key Return
xdotool key F5
#按F5
xdotool key F5
#按F5
Refer to Link:
转载于:https://blog.51cto.com/leonkuo/666550