How about using GetCursorPos, checking if it?¢_~s out of bounds and if it is using SetCursorPos to put the cursor where you want it.