|
-
Feb 7th, 2000, 03:22 AM
#1
Thread Starter
Lively Member
Hello,
I was wondering how my program can tell when a mouse button has been clicked outside of it, i.e. in explorer.
I've tryed subclassing but I've not had much luck.
Many thanks,
Desire
-
Feb 7th, 2000, 07:01 AM
#2
Use the GetAsyncKeystate API within a Timer Control, ie.
Code:
Private Declare Function GetForegroundWindow Lib "user32" () As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Const VK_LBUTTON = &H1
Private Const VK_RBUTTON = &H2
Private Sub Form_Load()
Timer1.Interval = 100
End Sub
Private Sub Timer1_Timer()
Dim sText As String
sText = Space(255)
sText = Left$(sText, GetWindowText(GetForegroundWindow, ByVal sText, 255))
If GetAsyncKeyState(VK_LBUTTON) Then
'Left Mouse Button Pressed...
Debug.Print "Left Click in [" & sText & "]"
ElseIf GetAsyncKeyState(VK_RBUTTON) Then
'Right Mouse Button Pressed..
Debug.Print "Right Click in [" & sText & "]"
End If
End Sub
------------------
Aaron Young
Analyst Programmer
[email protected]
[email protected]
Certified AllExperts Expert
-
Feb 8th, 2000, 03:15 AM
#3
Thread Starter
Lively Member
Thanks for the sample aaron it works great with the left and right mouse buttons but it doesn't recoginsed when my middle mouse button has been clicked. If you have any ideas about how to solve this then I would be most gratefull.
Many thanks,
Desire
-
Feb 8th, 2000, 04:05 AM
#4
Do the same thing and include an extra IF statement for VK_MBUTTON, the Constant Value is:
Private Const VK_MBUTTON = &H4
------------------
Aaron Young
Analyst Programmer
[email protected]
[email protected]
Certified AllExperts Expert
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
|