C# 获取鼠标在屏幕上的位置


获取鼠标位置及鼠标单击了哪个按键。
private void GetMousePoint()
{
     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.label1.Text = "Left";           
     if (mb == System.Windows.Forms.MouseButtons.Right) this.label1.Text = "Right";
     if (mb == System.Windows.Forms.MouseButtons.Middle) this.label1.Text = "Middle";

}

//更新鼠标位置等信息。
private void timer1_Tick(object sender, EventArgs e)
{
     GetMousePoint();
}




免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM