获取键盘鼠标信息的方法

作者在 2007-09-19 16:56:00 发布以下内容

Public Class Form1
 Public loop1 As Boolean = True
 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  Dim pMousePos As Point
  While loop1
   System.Windows.Forms.Application.DoEvents()
   pMousePos = Control.MousePosition
   Select Case Control.MouseButtons
    Case Windows.Forms.MouseButtons.Left
     MessageBox.Show("Mouse_Left(" & pMousePos.X.ToString & "," & pMousePos.Y.ToString & ")")
    Case Windows.Forms.MouseButtons.Middle
     MessageBox.Show("Mouse_Middle(" & pMousePos.X.ToString & "," & pMousePos.Y.ToString & ")")
    Case Windows.Forms.MouseButtons.None
     'MessageBox.Show("None")
    Case Windows.Forms.MouseButtons.Right
     MessageBox.Show("Mouse_Right(" & pMousePos.X.ToString & "," & pMousePos.Y.ToString & ")")
   End Select
  End While

 End Sub

 Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
  If e.KeyCode = Keys.Escape Then
   loop1 = False
  End If
 End Sub
End Class

小问题 | 阅读 1422 次
文章评论,共0条
游客请输入验证码
浏览69213次