wpf 获取桌面上的鼠标位置

先开一个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);//退出程序
        }
原文地址:https://www.cnblogs.com/lingLuoChengMi/p/10179917.html