返回指定窗口中所有控件的名称.
Controls := WinGetControls(WinTitle, WinText, ExcludeTitle, ExcludeText)
如果这些都未设置或省略, 将使用上次找到的窗口. 否则, 为 WinTitle 指定窗口标题或其他条件, 来标识目标窗口, 和/或为 WinText 指定目标窗口的单个文本元素的子字符串(由包含的 Window Spy 实用程序显示). 如果 DetectHiddenText 已经打开, 则检测隐藏文本元素. 标题或文本包含 ExcludeTitle 或 ExcludeText 的窗口将不被考虑.
类型: 数组
此函数返回一个包含指定窗口中所有控件的名称的数组. 每个控件名称由它的类名紧跟着它的序号(ClassNN), 如 Window Spy 所示.
例如, 如果将返回值赋值给名为 Controls 的变量, 并且存在两个控件, 则 Controls[1] 包含第一个控件的名称, Controls[2] 包含第二个控件的名称, 而 Controls.Length 返回该数字 2.
控件是按照 Z 轴顺序排序的, 如果窗口支持 Tab 键, Z 轴顺序通常与通过 Tab 导航的顺序相同.
如果找不到窗口, 则抛出 TargetError.
鼠标光标下的窗口或控件的 ID 可以使用 MouseGetPos 来获取.
窗口标题和文本是区分大小写的. 除非 DetectHiddenWindows 被打开, 否则不会检测隐藏窗口.
WinGetControlsHwnd, 窗口函数, 控件函数
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."
}