Title: Automatically move mouse to focused window
Tags: mouse;focus
Question: Is it possible to automatically move the mouse to anywhere in the window that has gained focus by a keystroke?
For example:
There are two monitors.
Mouse is near the left edge of the monitor on the left.
Using Alt+Tab, a window residing at the monitor on the right is switched and you have to move the mouse to this window.
It will be great to move the mouse into this window automatically or at least with a keyboard shortcut.
Comment: I suggested that for Unity a long time ago, but there was little interest. I don't know of any such software, although that would be quite nice.


Here is another answer: I just had the same need and ended up here looking for a solution to the problem.
As it doesn't seem like something that anybody else solved anywhere else, I used my basic shell skills to create the following script, which does the job using 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 &quot;$GEOMETRY&quot; | grep -Po &quot;[0-9]+x[0-9]+&quot;)
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
I've put this in a file and added a custom keyboard shortcut that runs it.

{'source': 'StackExchangeDataset', 'subset': 'askubuntu.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 1, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2014:00:11/01/14', 'FavoriteCount': 1.0, 'PostTypeId': 1, 'Tags': '<mouse><focus>', 'Title': 'Automatically move mouse to focused window', 'ViewCount': 802, 'id': 544492, 'user_AboutMe': None, 'user_AccountId': 1792343.0, 'user_DisplayName': 'Kadir', 'user_Reputation': 443.0, 'user_Views': 31.0, 'user_id': 153153.0}}