Z-Order von Fenstern ermitteln?

  • Hallo zusammen,


    wer kann mir sagen, wie ich die Reihenfolge, in der die Fenster übereinander auf dem Bildschirm liegen, herausfinde?
    Also sowas wie ein WinGetPos() mit Z-Order Rückgabe...

    Gruß
    pk

  • Hm,

    rein theoretisch sollte es so irgendwie Funktionieren, aber irgendwie listet es nicht alle Fenster auf ...

    Spoiler anzeigen
    [autoit]


    Global Const $user32dll = DllOpen ("user32.dll")

    [/autoit] [autoit][/autoit] [autoit]

    #include <Constants.au3>

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Global Const $MAX_PATH = 260
    Global Const $HWND_DESKTOP = 0

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func GetTopWindow ($hWnd)

    [/autoit] [autoit][/autoit] [autoit]

    Local $aRes = DllCall ($user32dll, 'HWND', 'GetTopWindow', _
    'HWND', $hWnd)
    Return $aRes[0]

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func GetNextWindow ($hWnd, $wCmd)

    [/autoit] [autoit][/autoit] [autoit]

    Local $aRes = DllCall ($user32dll, 'HWND', 'GetWindow', _
    'HWND', $hWnd, _
    'UINT', $wCmd)
    Return $aRes[0]

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func GetWindowText ($hWnd, ByRef $lpString, $nMaxCount)

    [/autoit] [autoit][/autoit] [autoit]

    Local $aRes = DllCall ($user32dll, 'INT', 'GetWindowTextW', _
    'HWND', $hWnd, _
    'WSTR', $lpString, _
    'INT', $nMaxCount)
    If (not @error) Then
    $lpString = $aRes[2]
    Return $aRes[0]
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func GetWindowZOrder ($hWnd)

    [/autoit] [autoit][/autoit] [autoit]

    Local $hwndTop
    Local $hwndNext
    Local $sText

    [/autoit] [autoit][/autoit] [autoit]

    $hwndTop = GetTopWindow ($hWnd)

    [/autoit] [autoit][/autoit] [autoit]

    If (not $hwndTop) Then _
    Return FALSE

    [/autoit] [autoit][/autoit] [autoit]

    GetWindowText ($hwndTop, $sText, $MAX_PATH)
    ConsoleWrite (StringFormat ("--- HWND: %s; Text: %s\n", $hwndTop, $sText))

    [/autoit] [autoit][/autoit] [autoit]

    $hwndNext = GetNextWindow ($hwndTop, $GW_HWNDNEXT)

    [/autoit] [autoit][/autoit] [autoit]

    GetWindowText ($hwndNext, $sText, $MAX_PATH)
    ConsoleWrite (StringFormat ("--- HWND: %s; Text: %s\n", $hwndNext, $sText))

    [/autoit] [autoit][/autoit] [autoit]

    While (($hwndNext = GetNextWindow ($hwndNext, $GW_HWNDNEXT)) <> 0)

    [/autoit] [autoit][/autoit] [autoit]

    GetWindowText ($hwndNext, $sText, $MAX_PATH)
    ConsoleWrite (StringFormat ("--- HWND: %s; Text: %s\n", $hwndNext, $sText))
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Return TRUE

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    WinActivate ("PoEdit")
    Sleep (500)
    GetWindowZOrder ($HWND_DESKTOP) ; Desktop = 0
    DllClose ($user32dll)
    Exit (0)

    [/autoit] [autoit][/autoit] [autoit]

    ;«««««««««««««««««««««««««««««««« End Of File «««««««««««««««««««««««««««««««««

    [/autoit]


    Gruß
    Greenhorn


  • Greenhorns Variante funktioniert einwandfrei^^

    Spoiler anzeigen
    [autoit]

    Global Const $user32dll = DllOpen ("user32.dll")

    [/autoit] [autoit][/autoit] [autoit]

    #include <Constants.au3>

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Global Const $MAX_PATH = 260
    Global Const $HWND_DESKTOP = 0

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func GetTopWindow ($hWnd)

    [/autoit] [autoit][/autoit] [autoit]

    Local $aRes = DllCall ($user32dll, 'HWND', 'GetTopWindow', _
    'HWND', $hWnd)
    Return $aRes[0]

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func GetNextWindow ($hWnd, $wCmd)

    [/autoit] [autoit][/autoit] [autoit]

    Local $aRes = DllCall ($user32dll, 'HWND', 'GetWindow', _
    'HWND', $hWnd, _
    'UINT', 2)

    [/autoit] [autoit][/autoit] [autoit]

    Return $aRes[0]

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func GetWindowText ($hWnd, ByRef $lpString, $nMaxCount)

    [/autoit] [autoit][/autoit] [autoit]

    Local $aRes = DllCall ($user32dll, 'INT', 'GetWindowTextW', _
    'HWND', $hWnd, _
    'WSTR', $lpString, _
    'INT', $nMaxCount)

    [/autoit] [autoit][/autoit] [autoit]

    If (not @error) Then
    $lpString = $aRes[2]
    Return $aRes[0]
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func GetWindowZOrder ($hWnd)

    [/autoit] [autoit][/autoit] [autoit]

    Local $hwndTop
    Local $hwndNext
    Local $sText

    [/autoit] [autoit][/autoit] [autoit]

    $hwndTop = GetTopWindow ($hWnd)
    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $hwndTop = ' & $hwndTop & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console

    [/autoit] [autoit][/autoit] [autoit]

    If (not $hwndTop) Then _
    Return FALSE

    [/autoit] [autoit][/autoit] [autoit]

    GetWindowText ($hwndTop, $sText, $MAX_PATH)

    [/autoit] [autoit][/autoit] [autoit]

    $hwndNext = GetNextWindow ($hwndTop, $GW_HWNDNEXT)

    [/autoit] [autoit][/autoit] [autoit]

    GetWindowText ($hwndNext, $sText, $MAX_PATH)

    [/autoit] [autoit][/autoit] [autoit]

    While ($hwndNext <> 0)
    $hwndNext = GetNextWindow ($hwndNext, $GW_HWNDNEXT)
    GetWindowText ($hwndNext, $sText, $MAX_PATH)
    ConsoleWrite (StringFormat ("--- HWND: %s; Text: %s\n", $hwndNext, $sText))
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Return TRUE

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    WinActivate ("PoEdit")
    Sleep (500)
    GetWindowZOrder ($HWND_DESKTOP) ; Desktop = 0
    DllClose ($user32dll)
    Exit (0)

    [/autoit] [autoit][/autoit] [autoit]

    ;«««««««««««««««««««««««««««««««« End Of File «««««««««««««««««««««««««««««««««

    [/autoit]

    das "überladen"

    [autoit]

    While (($hwndNext = GetNextWindow ($hwndNext, $GW_HWNDNEXT)) <> 0)

    [/autoit]

    ist aber AutoIt ein bisschen zu viel ;)

    ciao
    Andy


    "Schlechtes Benehmen halten die Leute doch nur deswegen für eine Art Vorrecht, weil keiner ihnen aufs Maul haut." Klaus Kinski
    "Hint: Write comments after each line. So you can (better) see what your program does and what it not does. And we can see what you're thinking what your program does and we can point to the missunderstandings." A-Jay

    Wie man Fragen richtig stellt... Tutorial: Wie man Script-Fehler findet und beseitigt...X-Y-Problem

    Einmal editiert, zuletzt von Andy (5. Oktober 2010 um 01:15)

  • Nicht schlecht, nicht schlecht!
    Das hilft mir alles schon sehr viel weiter.
    Danke für eure Mühe :)