先开一个Timer或者线程
DispatcherTimer timer = new DispatcherTimer(); timer.Interval = TimeSpan.FromMilliseconds(1000);//1秒 timer.Tick += Timer_Tick; timer.Start(); private void Timer_Tick(object sender, EventArgs e) { System.Drawing.Point pos = System.Windows.Forms.Cursor.Position; Console.WriteLine(pos); //System.Environment.Exit(0);//退出程序 }