Move mouse to active window
User Kadir posted a question on askubuntu.com:
Is it possible to automatically move the mouse to anywhere in the window that has gained focus by a key stroke?
Having sort of the same need, not finding a solution anywhere, I made a small shell script that does the job, which I posted as an answer:
# 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