Search code examples
c#mouse-cursor

What's the difference between using Cursor.Position, SetCursorPos(), SendInput() and mouse_event()?


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

So what's the difference between them?


Solution

    • 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.