WinGetControls

Returns an array of names (ClassNNs) for all controls in the specified window.

ClassNNs := WinGetControls(WinTitle, WinText, ExcludeTitle, ExcludeText)

パラメータ

WinTitle、WinText、ExcludeTitle、ExcludeText

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

もしこれらの項目が未設定または省略されたときは、最後に見つかったウィンドウが使用されます。そうでないときは、WinTitleウィンドウタイトルまたはターゲットウィンドウを識別するための他の基準、および/またはWinTextにターゲットウィンドウの単一のテキスト要素からの部分文字列(付属のWindow Spyユーティリティを使えばわかります)を指定します。

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

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

戻り値

型:配列

This function returns an array of names for all controls in the specified window. Each name consists of the control's class name followed immediately by its sequence number (ClassNN), as shown by Window Spy.

For example, if the return value is assigned to a variable named ClassNNs and two controls are present, ClassNNs[1] contains the name of the first control, ClassNNs[2] contains the name of the second control, and ClassNNs.Length returns the number 2.

コントロールはZオーダーに従ってソートされ、ウィンドウがタブ機能をサポートしているときは、通常、tabによるナビゲーションの順番と同じ順番になります。

エラー処理

ウィンドウが見つからないときは、TargetErrorがスローされます。

備考

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

WinGetControlsHwnd, Win functions, Control functions

アクティブウィンドウのコントロールリストから個々のコントロール名を抽出する。

for n, ctrl in WinGetControls("A")
{
    Result := MsgBox("Control #" n " is '" ctrl "'. Continue?",, 4)
    if (Result = "No")
        break
}

アクティブウィンドウのコントロールリストをリアルタイムで表示する。

SetTimer WatchActiveWindow, 200

WatchActiveWindow()
{
    try
    {
        Controls := WinGetControls("A")
        ControlList := ""
        for ClassNN in Controls
            ControlList .= ClassNN . "`n"
        if (ControlList = "")
            ToolTip "The active window has no controls."
        else
            ToolTip ControlList
    }
    catch TargetError
        ToolTip "No visible window is active."
}