C# 获取鼠标在屏幕上的位置
程序员文章站
2022-03-26 21:22:01
获取鼠标位置及鼠标单击了哪个按键。private void GetMousePoint(){ Point ms = Control.MousePosition; this.label2.Text = string.Format("当前鼠标位置:{0}:{1}", ms.X, ms.Y); Mouse... ......
获取鼠标位置及鼠标单击了哪个按键。
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();
}