Getting mouse position in c#

Athiwat Chunlakhan picture Athiwat Chunlakhan · Aug 22, 2009 · Viewed 358.2k times · Source

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.

Answer

RichieHindle picture RichieHindle · Aug 22, 2009

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