In addition to GetCursorPos, you may also consider using GetMouseMovePointsEx(). You can add the handle WM_MOUSEMOVE if it is Win32 application.