WinGetList

Returns an array of unique ID numbers (HWNDs) for all existing windows that match the specified criteria.

HWNDs := WinGetList(WinTitle, WinText, ExcludeTitle, ExcludeText)

パラメータ

WinTitle、WinText、ExcludeTitle、ExcludeText

型:文字列整数またはオブジェクト

If each of these is blank or omitted, all windows on the entire system will be retrieved. そうでないときは、<e1>WinTitle</e1>に <a2>ウィンドウタイトル</a2>またはターゲットウィンドウを識別するための<a2>他の基準</a2>、および/または<e3>WinText</e3>にターゲットウィンドウの単一のテキスト要素からの部分文字列(付属のWindow Spyユーティリティを使えばわかります)を指定します。

ExcludeTitleExcludeTextはウィンドウのタイトルまたはテキストで除外するために使用します。指定の仕方はWinTitleWinTextに似ていますが、ExcludeTitleはウィンドウのタイトル以外の基準(ウィンドウクラスやHWNDなど)を認識しません。

ウィンドウのタイトルとテキストは大文字と小文字を区別します。DetectHiddenWindows関数 と DetectHiddenText関数で変更しない限り、初期設定では非表示ウィンドウは検出されず、非表示テキストは検出されます。SetTitleMatchMode関数で変更しない限り、初期設定ではウィンドウのタイトルはその中のどこかにWinTitleまたはExcludeTitleを含んでいれば一致します。

戻り値

型:配列

This function returns an array of unique ID numbers for all existing windows that match the specified criteria. ナンバーはウィンドウハンドル(HWND)です。</a0マッチするウィンドウがない場合は、空の配列が返される。

For example, if the return value is assigned to a variable named HWNDs and two matching windows are discovered, HWNDs[1] contains the ID of the first window, HWNDs[2] contains the ID of the second window, and HWNDs.Length returns the number 2.

ウィンドウは、(デスクトップ上の積み重ね方に従って)最上位から最下位へと順番に検索される。

備考

マウスカーソルの下にあるウィンドウのIDは、MouseGetPos関数で取得できます。

WinGetCount, Win functions, Control functions

システム全体のすべてのウィンドウを訪問し、それぞれのウィンドウに関する情報を表示する。

ids := WinGetList(,, "Program Manager")
for this_id in ids
{
    WinActivate this_id
    this_class := WinGetClass(this_id)
    this_title := WinGetTitle(this_id)
    Result := MsgBox(
    (
        "Visiting All Windows
        " A_Index " of " ids.Length "
        ahk_id " this_id "
        ahk_class " this_class "
        " this_title "

Continue?"
    ),, 4)
    if (Result = "No")
        break
}