Функция _WinAPI_GetWindow

 ↑  ←  Описание функции


_WinAPI_GetWindow

Возвращает дескриптор окна, который имеет указанную связь по отношению к указанному окну

#include <WinAPI.au3>
_WinAPI_GetWindow($hWnd, $iCmd)

Параметры

$hWnd Дескриптор окна
$iCmd Определяет связь между указанным окном и окном, дескриптор которого будет получен. Этот параметр может быть одним из следующих значений:
    $GW_CHILD - The retrieved handle identifies the child window at the top of the Z order, if the specified window is a parent window; otherwise, the retrieved handle is 0. The function examines only child windows of the specified window. It does not examine descendant windows.
    $GW_HWNDFIRST - The retrieved handle identifies the window of the same type that is highest in the Z order. If the specified window is a topmost window, the handle identifies the topmost window that is highest in the Z order. If the specified window is a top-level window, the handle identifies the top level window that is highest in the Z order. If the specified window is a child window, the handle identifies the sibling window
    that is highest in the Z order.
    $GW_HWNDLAST - The retrieved handle identifies the window of the same type that is lowest in the Z order. If the specified window is a topmost window, the handle identifies the topmost window that is lowest in the Z order. If the specified window is a top-level window the handle identifies the top-level window that's lowest in the Z order. If the specified window is a child window, the handle identifies the sibling window that is
    lowest in the Z order.
    $GW_HWNDNEXT - The retrieved handle identifies the window below the specified window in the Z order. If the specified window is a topmost window, the handle identifies the topmost window below the specified window. If the specified window is a top-level window, the handle identifies the top-level window below the specified window. If the specified window is a child window the handle identifies the sibling window below the
    specified window.
    $GW_HWNDPREV - The retrieved handle identifies the window above the specified window in the Z order. If the specified window is a topmost window, the handle identifies the topmost window above the specified window. If the specified window is a top-level window, the handle identifies the top-level window above the specified window. If the specified window is a child window, the handle identifies the sibling window above the
    specified window.
    $GW_OWNER - The retrieved handle identifies the specified window's owner window if any

Возвращаемое значение

Успех:Возвращает дескриптор окна
Ошибка:Возвращает 0

Примечания

Для выше указанных констант необходим Constants.au3

См. также

Искать GetWindow в библиотеке MSDN

Пример

#include <Constants.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <WinAPI.au3>

Local $iArraySize = 1, $i = 0, $aWinList[$iArraySize][4] = [[0]]

$hWnd = DllCall("user32.dll", "hwnd", "FindWindow", "int", 0, "int", 0)
If Not @error Then
    $hWnd = $hWnd[0]
EndIf
While $hWnd
    $i += 1
    If $i >= $iArraySize Then
        $iArraySize = $i * 2
        ReDim $aWinList[$iArraySize][4]
    EndIf
    $aWinList[$i][0] = $hWnd ; Дескриптор
    $aWinList[$i][1] = _WinAPI_GetWindowText($hWnd) ; Заголовок
    $aWinList[$i][2] = _WinAPI_GetClassName($hWnd) ; Класс
    If BitAND(_WinAPI_GetWindowLong($hWnd, $GWL_STYLE), $WS_VISIBLE) Then
        $aWinList[$i][3] = 'Видимо'
    Else
        $aWinList[$i][3] = 'Скрыто'
    EndIf
    $hWnd = _WinAPI_GetWindow($hWnd, $GW_HWNDNEXT)
WEnd
If $i Then
    ReDim $aWinList[$i + 1][4]
    $aWinList[0][0] = $i
EndIf
; _ArrayDisplay($aWinList, 'Результат', -1, 0, '', '|', '№|Дескриптор|Заголовок|Класс|Видимость')
_ArrayDisplay($aWinList, 'Результат')