| 
    
     |  | EnumChildWindowsとか、FindWindowsEXで再帰かけるとか。 
 Private Declare Function GetWindowText Lib "user32" _
 Alias "GetWindowTextA" _
 (ByVal hwnd As Long, ByVal lpString As String, _
 ByVal nMaxCount As Long) As Long
 Private Declare Function GetClassName Lib "user32" _
 Alias "GetClassNameA" _
 (ByVal hwnd As Long, ByVal lpClassName As String, _
 ByVal nMaxCount As Long) As Long
 Private Declare Function FindWindowEx Lib "user32" _
 Alias "FindWindowExA" _
 (ByVal hwndParent As Long, ByVal hwndChildAfter As Long, _
 ByVal lpszClass As String, ByVal lpszWindow As String) As Long
 Private Declare Function IsWindowVisible Lib "user32" _
 (ByVal hwnd As Long) As Long
 
 Private Sub GetChilds(ByVal hwndParent As Long, _
 Optional r As Long, Optional ByVal c As Long = 1)
 
 Dim h As Long
 Dim sClass As String
 Dim sText As String
 Do
 h = FindWindowEx(hwndParent, h, vbNullString, vbNullString)
 If h = 0 Then Exit Do
 If IsWindowVisible(h) Then
 r = r + 1
 
 sClass = String$(80, 0)
 sText = String$(80, 0)
 GetClassName h, sClass, Len(sClass)
 GetWindowText h, sText, Len(sText) - 1
 sClass = Left$(sClass, InStr(sClass, vbNullChar) - 1)
 sText = Left$(sText, InStr(sText, vbNullChar) - 1)
 
 With ActiveSheet.Cells(r, c)
 .Value = Right$(String$(7, "0") & Hex$(h), 8) & _
 ", " & sClass & ", " & sText
 End With
 sClass = vbNullString: sText = vbNullString
 
 GetChilds h, r, c + 1
 End If
 Loop
 End Sub
 
 Sub Test()
 ActiveSheet.Cells.Clear
 GetChilds FindWindowEx(0, 0, "FNWND380", "Main_Window")
 End Sub
 
 
 |  |