I have a form, with a textbox in it. When I start my application I want that textbox to contain the cursor position on screen, even if the cursor is out of my form. How can I do this?
My code is the following but it works only when the cursor is on the form:
protected override void OnMouseMove( MouseEventArgs e )
{
mousePos.Text = Cursor.Position.ToString();
base.OnMouseMove( e );
}
Create a
System.Windows.Forms.Timerwith an interval of 100 milliseconds, and put your function inside theTimer.Tickevent handler.