Point ms = Control.MousePosition; //获取鼠标位置 this.label2.Text = string.Format("{0}:{1}", ms.X, ms.Y); MouseButtons mb= Control.MouseButtons; //获取鼠标按键 if (mb == System.Windows.Forms.MouseButtons.Left) this.label3.Text = "Left"; if (mb == System.Windows.Forms.MouseButtons.Right) this.label3.Text = "Right"; if (mb == System.Windows.Forms.MouseButtons.Middle) this.label3.Text = "Middle";
通过以上代码可以获取鼠标在屏幕上的位置信息,以及鼠标按下的键的信息.