Danke eknori,
leider liefert mir die Funktion "isWindowEnabled" immer True zurück, auch wenn das Fenster minimiert ist. Hast Du vielleicht noch eine andere Idee?
Hier der Code, damit es etwas klarer wird!
Declarations:
| Declare Function GetWindow Lib "user32" ( Byval hWnd As Long, Byval wCmd As Long) As Long |
| Declare Function GetWindowText Lib "user32.dll" Alias "GetWindowTextA" (Byval hwnd As Long, Byval lpString As String, Byval cch As Long) As Long |
| Declare Function GetForegroundWindow Lib "user32.dll" () As Long |
| Declare Function IsWindowEnabled Lib "user32" Alias "IsWindowEnabled" ( Byval hwnd As Long ) As Long |
| Declare Function IsWindowVisible Lib "user32" Alias "IsWindowVisible" ( Byval hwnd As Long ) As Long |
| |
| Const GW_HWNDNEXT = 2 |
und die Funktion:
| |
| |
| |
| |
| |
| Function FindWindowLike(Teilstring As String) As Long |
| Dim hWnd As Long |
| Dim strCurrentWindowText As String |
| Dim r As Integer |
| Dim ret As Boolean |
| |
| hWnd = GetForegroundWindow |
| |
| |
| Do Until hWnd = 0 |
| strCurrentWindowText = Space$(255) |
| r = GetWindowText(hWnd, strCurrentWindowText, 255) |
| strCurrentWindowText = Left$(strCurrentWindowText, r) |
| If Instr(1, Lcase(strCurrentWindowText), Lcase(Teilstring)) <> 0 Then Goto Found |
| hWnd = GetWindow(hWnd, GW_HWNDNEXT) |
| Loop |
| Exit Function |
| |
| Found: |
| FindWindowLike = hWnd |
| |
| |
| ret = iswindowenabled (hWnd) |
| ret1 = iswindowvisible(hWnd) |
| |
| Dim text As String |
| text = Cstr(Now) & " Ergebnis, Fensterhandle = " & Cstr(strCurrentWindowText) & Cstr(findwindowlike) & " Enabled = " & Cstr(ret) & Cstr(ret1) |
| End Function |
iswindowvisible liefert True
iswindowenabled liefert ebenfalls True
Das Fenster ist aber zum Testzeitpunkt definitiv minimiert, und es wird das richtige Fenster ermittelt (strCurrentWindowText).
Noch ne Idee?
Grüße, Klaus