Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Type POINTAPI
x As Long
y As Long
End Type
Dim MousePos As POINTAPI
Private Sub Form_load()
MsgBox "Для выхода из программы, нажмите ESC"
Do
GetCursorPos MousePos
If KeyDown(1) Then
MsgBox "Вы нажали левую кнопку мыши в (x=" & MousePos.x & ", y=" & MousePos.y & ")"
End If
If KeyDown(2) Then
MsgBox "Вы нажали правую кнопку мыши в (x=" & MousePos.x & ", y=" & MousePos.y & ")"
End If
If KeyDown(vbKeyEscape) Then
End
End If
Sleep 10
DoEvents
Loop
End Sub
Function KeyDown(Key As Long) As Boolean
If GetKeyState(Key) = -127 Or GetKeyState(Key) = -128 Then
KeyDown = True
End If
End Function
Сейчас этот форум просматривают: SemrushBot и гости: 145