tags:

views:

469

answers:

1

Cursor.Position, SetCursorPos(), SendInput() and mouse_event() all set the mouse position to a specified coordinate.

So what's the difference between them?

+1  A: 
  • Cursor.Position and SetCursorPos can only be used to change the cursor position. Cursor.Position is Windows Forms; SetCursorPos is Win32.

  • SendInput and mouse_event can be used to change the cursor position as well as generate mouse clicks and mouse wheel events. SendInput is the current API; in addition to generating mouse events, it can also generate keyboard input. mouse_event is an earlier, deprecated API.

Martin B
Do Cursor.Position and SetCursorPos use SendInput internally; or do they differ in implementation?
Ashley Simpson
I have to admit I don't know, and I don't think this is documented anywhere. The closest you can get to an answer is probably to take a look at the implementation of SetCursorPos in Wine (www.winehq.com). If it uses SendInput, then that should be evidence that SetCursorPos is at least functionally equivalent to a subset of SendInput -- which is all that should matter.
Martin B