Hallo Heiko,
versuch es mal damit:
Option Explicit
Private Declare Function EnumWindows Lib "user32.dll" ( _
ByVal lpEnumFunc As Long, _
ByVal lParam As Long) As Boolean
Private Declare Function GetWindowText Lib "user32.dll" Alias "GetWindowTextA" ( _
ByVal hWnd As Long, _
ByVal lpString As String, _
ByVal cch As Long) As Long
Private Declare Function GetWindowTextLength Lib "user32.dll" Alias "GetWindowTextLengthA" ( _
ByVal hWnd As Long) As Long
Private Declare Function GetClassName Lib "user32.dll" Alias "GetClassNameA" ( _
ByVal hWnd As Long, _
ByVal lpClassName As String, _
ByVal nMaxCount As Long) As Long
Private Declare Function GetWindowLong Lib "user32.dll" Alias "GetWindowLongA" ( _
ByVal hWnd As Long, _
ByVal wIndx As Long) As Long
Private Const GWL_STYLE = -&H10
Private Const WS_VISIBLE = &H10000000
Private Const WS_BORDER = &H800000
Private lngRow As Long
Public Sub prcStart()
lngRow = 0
With ThisWorkbook.Worksheets(1)
.UsedRange.ClearContents
EnumWindows AddressOf fncWindows, ByVal 0&
.Columns.AutoFit
.Columns("A:C").Sort Key1:=Cells(1, 2)
End With
End Sub
Private Function fncWindows(ByVal hWnd As Long, ByVal lParam As Long) As Boolean
Dim strTemp As String, lngReturn As Long, strClassName As String * 100
Dim lngStyle As Long
lngStyle = GetWindowLong(hWnd, GWL_STYLE) And (WS_VISIBLE Or WS_BORDER)
lngReturn = GetWindowTextLength(hWnd)
strTemp = Space(lngReturn)
GetWindowText hWnd, strTemp, lngReturn + 1
' If lngStyle = (WS_VISIBLE Or WS_BORDER) And lngReturn <> 0 Then 'sichtbare Fenster
If lngReturn <> 0 Then 'alle Fenster
lngRow = lngRow + 1
GetClassName hWnd, strClassName, 100
With ThisWorkbook.Worksheets(1)
.Cells(lngRow, 1) = hWnd
.Cells(lngRow, 2) = strTemp
.Cells(lngRow, 3) = Trim(strClassName)
End With
End If
fncWindows = True
End Function
Die Klassennamen, Titel und Handles werden in einer Exceltabelle ausgegeben. Über den Klassennamen kannst du mit FindWindow prüfen, ob das Fenster angezeigt wird. Benutz dazu einen Timer, der das in 10ms - Takt prüft.
------------------
Gruß
Nepumuk
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP