检查 WinList() 是否包含某个标题
Check if WinList() contains a certain title
我正在列出所有打开的 windows 使用 WinList()
在 AutoIt 中获取 window 标题和句柄。
我想检查结果数组是否包含特定标题。做这个的最好方式是什么?没有 WinList().Contains("TitleName")
或类似的东西。
Local $aList = WinList() ;Gets a list of Window Titles and IDs
好的,我明白了:
For $i = 1 To $aList[0][0]
If $aList[$i][0] = "Title/String you search for" Then
MsgBox($MB_SYSTEMMODAL, "", "MessageBox shows this text if title is in list.")
EndIf
Next
您也可以使用与您所写内容类似的内容。
#include <Array.au3>
Opt("WinDetectHiddenText", 0) ;0=don't detect, 1=do detect
Opt("WinSearchChildren", 0) ;0=no, 1=search children also
Opt("WinTextMatchMode", 1) ;1=complete, 2=quick
Opt("WinTitleMatchMode", 1) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
Local $title = 'AutoIt Help (v3.3.14.2)'
Local $aList = WinList()
;~ _ArrayDisplay($aList)
Local $iIndex = _ArraySearch($aList,$title)
WinActivate($aList[$iIndex][1], '')
Window 存在吗?
"I am listing all open windows … I want to check if … contains a specific title. What is the best way to do this?"
根据Documentation - Function Reference - WinExists()
:
Checks to see if a specified window exists.
示例。
Global Const $g_sWndTitle = 'Window title here'
If WinExists($g_sWndTitle) Then WinFlash($g_sWndTitle)
检索window句柄、-文本和-标题
句柄
"… to get window title and -handle …"
根据Documentation - Function Reference - WinGetHandle()
:
Retrieves the internal handle of a window.
示例:
Global Const $g_sWndTitle = 'Window title here'
Global $g_hWnd
If WinExists($g_sWndTitle) Then
$g_hWnd = WinGetHandle($g_sWndTitle)
WinFlash($g_hWnd)
EndIf
文字
根据Documentation - Function Reference - WinGetText()
:
Retrieves the text from a window.
示例:
Global Const $g_sWndTitle = 'Window title here'
If WinExists($g_sWndTitle) Then
WinFlash($g_sWndTitle)
ConsoleWrite(WinGetText($g_sWndTitle) & @CRLF)
EndIf
标题
同样,WinGetTitle()
.
我正在列出所有打开的 windows 使用 WinList()
在 AutoIt 中获取 window 标题和句柄。
我想检查结果数组是否包含特定标题。做这个的最好方式是什么?没有 WinList().Contains("TitleName")
或类似的东西。
Local $aList = WinList() ;Gets a list of Window Titles and IDs
好的,我明白了:
For $i = 1 To $aList[0][0]
If $aList[$i][0] = "Title/String you search for" Then
MsgBox($MB_SYSTEMMODAL, "", "MessageBox shows this text if title is in list.")
EndIf
Next
您也可以使用与您所写内容类似的内容。
#include <Array.au3>
Opt("WinDetectHiddenText", 0) ;0=don't detect, 1=do detect
Opt("WinSearchChildren", 0) ;0=no, 1=search children also
Opt("WinTextMatchMode", 1) ;1=complete, 2=quick
Opt("WinTitleMatchMode", 1) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
Local $title = 'AutoIt Help (v3.3.14.2)'
Local $aList = WinList()
;~ _ArrayDisplay($aList)
Local $iIndex = _ArraySearch($aList,$title)
WinActivate($aList[$iIndex][1], '')
Window 存在吗?
"I am listing all open windows … I want to check if … contains a specific title. What is the best way to do this?"
根据Documentation - Function Reference - WinExists()
:
Checks to see if a specified window exists.
示例。
Global Const $g_sWndTitle = 'Window title here'
If WinExists($g_sWndTitle) Then WinFlash($g_sWndTitle)
检索window句柄、-文本和-标题
句柄
"… to get window title and -handle …"
根据Documentation - Function Reference - WinGetHandle()
:
Retrieves the internal handle of a window.
示例:
Global Const $g_sWndTitle = 'Window title here'
Global $g_hWnd
If WinExists($g_sWndTitle) Then
$g_hWnd = WinGetHandle($g_sWndTitle)
WinFlash($g_hWnd)
EndIf
文字
根据Documentation - Function Reference - WinGetText()
:
Retrieves the text from a window.
示例:
Global Const $g_sWndTitle = 'Window title here'
If WinExists($g_sWndTitle) Then
WinFlash($g_sWndTitle)
ConsoleWrite(WinGetText($g_sWndTitle) & @CRLF)
EndIf
标题
同样,WinGetTitle()
.