獲取滑鼠位置及滑鼠單擊了哪個按鍵。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();
}