Search code examples
c#mouse-position

Getting mouse position in c#


How do I get the mouse position? I want it in term of screen position.

I start my program I want to set to the current mouse position.

Location.X = ??
Location.Y = ??

Edit: This must happen before the form is created.


Solution

  • You should use System.Windows.Forms.Cursor.Position: "A Point that represents the cursor's position in screen coordinates."