The API function that you were thinking of is probably TrackMouseEvent.
Click this smily: