|
-
Jun 20th, 2000, 08:42 PM
#1
Thread Starter
Addicted Member
Hi
Hi
I need to know when a Mouse button clicks or has been pushed Down on other Applications
-
Jun 22nd, 2000, 05:29 PM
#2
Use the GetASyncKeyState to trap when the mouse has been pressed/is down.
Example:
Add a timer called Timer1 to a form set its interval to 100.
Insert the followinf code
Code:
Option Explicit
Private Const VK_LBUTTON As Long = &H1 '//Left mouse button
Private Const VK_RBUTTON As Long = &H2 '//Right mouse button
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Sub Timer1_Timer()
Dim lRet As Long
lRet = GetAsyncKeyState(VK_LBUTTON)
If lRet <> 0 Then
Debug.Print "Left Mouse is " & TranslateValue(lRet)
End If
lRet = GetAsyncKeyState(VK_RBUTTON)
If lRet <> 0 Then
Debug.Print "Right Mouse is " & TranslateValue(lRet)
End If
End Sub
Private Function TranslateValue(ByVal lValue As Long) As String
Select Case lValue
Case 0 'Nothing, 'key' hasn't been pressed
Case 1 'Huh?
TranslateValue = "Unkown state"
Case -32767 'Click, first recording of 'key'press
TranslateValue = "Pressed"
Case -32768 ''Key' is down
TranslateValue = "Down"
Case Else 'Another, hmmm whats this
TranslateValue = "Unkown state"
End Select
End Function
Hope it helps,
-
Jun 23rd, 2000, 05:12 PM
#3
Thread Starter
Addicted Member
Grate It works fine but could you also tell me how to detect other events like dblclicks?
Thanks a lot
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|