you can use Cursor.Position
:
textBox1.Text = Cursor.Position.X.ToString();
textBox2.Text = Cursor.Position.Y.ToString();
btw , welcome to SO , please Consider searching the site before asking questions.
and for getting these result every 50 ms you need to use Timer
, here's a tutorial for Timer
: C# Timer Tutorial
Update :
private void Form1_Load(object sender, EventArgs e)
{
Timer t1 = new Timer();
t1.Interval = 50;
t1.Tick += new EventHandler(timer1_Tick);
t1.Enabled = true;
}
private void timer1_Tick(object sender, EventArgs e)
{
textBox1.Text = Cursor.Position.X.ToString();
textBox2.Text = Cursor.Position.Y.ToString();
}