Windows contains settings to hide mouse pointer while typing, but doesn't contains a settings to move pointer to active typing area. I mean I can switch typing areas by tab, or enter, or alt+tab, etc. but my pointer is still far away. What I should use (program, script, autohotkey script) to make similar system-wide behavior?
AutoHotkey will let you assign a shortcut key to move the mouse to the current cursor location if that's what you're after.
#a:: ; shortcut key is <Win>+a CoordMode, Caret, Screen ; set Caret to use Screen Coordinates CoordMode, Mouse, Screen ; set Mouse to use Screen Coordinates MouseMove, %A_CaretX%, %A_CaretY% ; move mouse to caret position return
You could also assign the script to run after certain events where you know the cursor focus will change
~!Tab Up:: keywait, Alt ; wait for user to let off alt key after activation sleep 200 ; give the selected program time to activate gosub #a ; move the mouse return
To do this, you need to use a DllCall to get the true caret position. The following works for me everywhere I tested it (including MS Word, which doesn't work with A_CaretX/Y).
#s:: ;assign hotkey to win + s ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms632604(v=vs.85).aspx VarSetCapacity(GuiThreadInfo, 48) ;create "struct" NumPut(48, GuiThreadInfo,,"UInt") ;update cbSize member ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms633506(v=vs.85).aspx DllCall("GetGUIThreadInfo", int, 0, ptr, &GuiThreadInfo) hwnd := NumGet(&GuiThreadInfo+7*4) ;get 7th member of struct left := NumGet(&GuiThreadInfo+8*4) ;8th member top := NumGet(&GuiThreadInfo+9*4) ;9th ControlGetPos, x, y,,,,ahk_id %hwnd% ;get position of active control, relative to window MouseMove, left+x, top+y return