Karabiner comes with everything you need—a way to define a shortcut, and a way to move the mouse. The
warp-mouse-cursor-position utility lives in
It has a default setting to warp the mouse to the center of the current window by tapping fn or holding ' or /, but for a customized version, add this to your
~/Library/Application Support/Karabiner/private.xml: (After you’re done, go into Karabiner’s preferences and check the box inside Mouse Warping.)
/Applications/Karabiner.app/Contents/Library/utilities/bin/warp-mouse-cursor-position front_window middle 0 center 0
<name>F14 to move the mouse to the center of the current window</name>
With Karabiner's utility, you can use the
screen option like this:
warp-mouse-cursor-position screen NUM VERTICAL X_OFFSET HORIZONTAL Y_OFFSET
VERTICAL can be
HORIZONTAL can be
Y_OFFSET can be numerical values, like
-10. Just be careful to put the arguments in the right order—they seem oddly switched.
(For the front window, just use
front_window instead of
Probably the most popular way, but in order to use it for moving to the middle of a window, you’d need an AppleScript to get the bounds of the current window, then calculate the center, etc.