下面是模拟窗体的双击事件
Private Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
Private Const MOUSEEVENTF_LEFTDOWN = &H2 '模拟鼠标左键按下
Private Const MOUSEEVENTF_LEFTUP = &H4 '模拟鼠标左键抬起
Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
Private Sub Form_dblClick()
MsgBox "双击"
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyA Then '按下A即是双击了窗体,即触发了form的dblclick事件,A为热键
mouse_event MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
mouse_event MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
End If
If KeyCode = vbKeyQ Then ' 按下Q结束程序
End
End If
End Sub
Private Sub Timer1_Timer()
SetCursorPos (Me.Left + 1000) / Screen.TwipsPerPixelX, (Me.Top + 1000) / Screen.TwipsPerPixelY ' 设置鼠标的位置在窗体上
End Sub