you can use FindWindow to get the external window's handle, then WindowFromPt to know when the user is hovering over this window, and GetAsyncKeyState to know when the mouse has been clicked. but since you only want to trigger this event when they have clicked on the caption bar you would need to use GetWindowPlacement and subtract the Top Left coordinate of the window from the Y coordinate of the mouse to tell if the mouse was in the caption bar region. I think there may be an easier way but researching it may take more time than just doing this, which really is not much work at all if you know the APIs,
Thanks. I found what I was looking for after reading your reply and it lead me to the proper process. I thought that I'd share the result. I simply waited for the next mouseclick and then pulled the windows coordinates at that point. Checked the class and caption to confirm that it was the application that I wanted the user to identify. Then I continued on from there...
Thanks Again...
Mike
For anyone else that needed to know how to wait I've left the following code here for your help. I did not include all the necessary API declarations. Only the one for determining the Mouse Click while waiting.
----------------------
Declare Function GetAsyncKeyState Lib "User32" (ByVal Key As Integer) As Integer
Function Button_Click
' Call GetAsyncKeyState in the Debug line below to clear the KeyState of the mouse click for this Function
' Check for both mouse events in case Left Handed User.
Debug.Print "LastKey= " & GetAsyncKeyState(1)
Do
DoEvents
If GetAsyncKeyState(1) <> 0 Then '(1) = Left Mouse Click
Debug.Print "Mouse Left Clicked"
Exit Do
End If
If GetAsyncKeyState(2) <> 0 Then '(2) = Right Mouse Click
Debug.Print "Mouse Right Clicked"
Exit Do
End If
Loop
mfx = MouseX()
mfy = MouseY()
' Get Window Handle
frwnd = WindowFromPoint(mfx, mfy)
' Now bring that Window to TOP...
ttr = IsWindowVisible(frwnd) ' 1=true
If ttr = 1 Then
ttr = IsIconic(frwnd)
Else
Debug.Print ("Invalid Window"
Exit Function
End If
If ttr = 0 Then ' Not an Icon
ttr = BringWindowToTop(frwnd) '0 = False 1=True
Else
Debug.Print("Icon"
ShowWindow frwnd, SW_RESTORE
ttr = BringWindowToTop(frwnd) '0 = False 1=True
End If
' Check to make sure window is a CORRECT Window
Call CheckClass(frwnd)
If mc.checkclass = False then exit function
Dim WinTitleBuf1 As String * 255
Dim WinTitle1 As String
If Mid(WinTitle1, 3, 6) = "CAPTION" Or Mid(WinTitle1, 3, 6) = "CAPTION" Then
RHWND = frwnd
Debug.Print ("Found Correct Window: " & frwnd)
Exit Function
Else
'Debug.Print "No" ' NO this is not the proper window
MsgBox ("Please Select the Proper Window"
RHWND = 0
Exit Function
End If
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.