Wednesday, March 13, 2013

Get the Cursor Position

using System.Runtime.InteropServices;

[DllImport("user32.dll")]
static extern bool GetCursorPos(ref Point lpPoint);

Point defPnt = new Point();
GetCursorPos(ref defPnt);

string CoordinatesXnY  = "X = " + defPnt.X.ToString() + "Y = " + defPnt.Y.ToString();

No comments:

Post a Comment