Code: Select all
Option Explicit
Private Declare PtrSafe Function apiGetDesktopWindow Lib "user32" Alias _
"GetDesktopWindow" () As Long
Private Declare PtrSafe Function apiGetWindow Lib "user32" Alias _
"GetWindow" (ByVal hwnd As Long, _
ByVal wCmd As Long) As Long
Private Declare PtrSafe Function apiGetWindowText Lib "user32" Alias _
"GetWindowTextA" (ByVal hwnd As Long, ByVal _
lpString As String, ByVal aint As Long) As Long
Private Declare PtrSafe Function apiGetWindowLong Lib "user32" Alias _
"GetWindowLongA" (ByVal hwnd As Long, ByVal _
nIndex As Long) As Long
Private Const GW_CHILD As Long = 5
Private Const GW_HWNDNEXT As Long = 2
Private Const GWL_STYLE As Long = (-16)
Private Const mconMAXLEN = 255
Public Sub ChromeInfo()
Dim hwnd As Long, sWinTxt As String, iLength As Long, iHandleStyle As Long
Dim v As Variant
hwnd = apiGetWindow(apiGetDesktopWindow(), GW_CHILD)
Do While hwnd <> 0
sWinTxt = String$(mconMAXLEN - 1, 0)
iLength = apiGetWindowText(hwnd, sWinTxt, mconMAXLEN)
If iLength > 0 Then
sWinTxt = left$(sWinTxt, iLength)
iHandleStyle = apiGetWindowLong(hwnd, GWL_STYLE)
If iHandleStyle And WS_VISIBLE Then
v = Split(sWinTxt, "-")
If v(UBound(v)) = " Google Chrome" Then
MsgBox "Need to get Chrome URL for " & v(0)
End If
End If
End If
hwnd = apiGetWindow(hwnd, GW_HWNDNEXT)
Loop
End Sub