|
-
Nov 23rd, 1999, 01:27 AM
#1
Thread Starter
New Member
I need to get the current mouse position (using GetCursorPos API) for a mouse click event occurring at a different app than mine. I have tried the SetCapture but it goes away as soon as the other window is clicked.
-
Nov 23rd, 1999, 01:31 AM
#2
You can use the GetAsyncKeyState API to detect a Mouse Click anywhere in the OS:
Add a Timer Control to a Form and use this Code..
Code:
Private Type POINTAPI
x As Long
y As Long
End Type
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Sub Form_Load()
Timer1.Interval = 100
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Dim tPA As POINTAPI
If GetAsyncKeyState(vbLeftButton) Then
Call GetCursorPos(tPA)
Caption = tPA.x & ":" & tPA.y
End If
End Sub
------------------
Aaron Young
Analyst Programmer
[email protected]
[email protected]
-
Nov 23rd, 1999, 01:55 AM
#3
Thread Starter
New Member
I have done it with the timer control, but want to do it without by detecting the mouse click event. Thanks
-
Nov 23rd, 1999, 02:01 AM
#4
The Only Way to Check the Mouse Click Event other than in a Timer Event using the GetAsyncKeyState API is to Check for the WM_RBUTTONDOWN Message, but as you cannot check Message Queues outsite your Thread, (i.e Other Apps), the Timer Control is your only viable solution.
Someone feel free to correct me if I'm wrong.
------------------
Aaron Young
Analyst Programmer
[email protected]
[email protected]
[This message has been edited by Aaron Young (edited 11-23-1999).]
-
Nov 23rd, 1999, 02:50 AM
#5
Thread Starter
New Member
Guess I was looking for a callback method. Been beating a bunch of options and have not been able to get it.
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
|