是否可以将鼠标自动移动到通过按键获得焦点的窗口中的任何位置?
例如:
我只是有同样的需求,最终来到这里寻找问题的解决方案。
由于这看起来不像其他人在其他地方解决过的问题,因此我使用基本的 shell 技能创建了以下脚本,该脚本使用以下命令完成这项工作xdotool:
# Get geometry information of the currently active window.
GEOMETRY=`xdotool getwindowgeometry $(xdotool getactivewindow)`
# Extract information about the dimensions of the window and divide
# both of them by 2.
DIMENSIONS=$(echo "$GEOMETRY" | grep -Po "[0-9]+x[0-9]+")
X=$(echo $DIMENSIONS | sed 's/x[0-9]\+//g')
Y=$(echo $DIMENSIONS | sed 's/[0-9]\+x//g')
X=$(expr $X / 2)
Y=$(expr $Y / 2)
# Move the mouse cursor to the middle of the active window.
xdotool mousemove -w $(xdotool getactivewindow) $X $Y
Run Code Online (Sandbox Code Playgroud)
我已将其放入文件中,并添加了运行它的自定义键盘快捷键。