#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Run_Tidy=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include #include #include _Main() ; ****************************** ; GLOBAL SETTINGS ; AutoItSetOption("WinTitleMatchMode", 2) ; match ANY substring in the title Break($BREAK_ENABLE) ; ; ****************************** Func FindAllWindows($titlematch) Local $NonHIWindowCount = 0 Local $AllWindowsCount = 0 Local $AllWindows Local $i Local $WindowsDupe[10][2] ; arbitrary size, will ReDim later Local $TitleMatchCount = 0 Local $temp $AllWindows = WinList() ;_ArrayDisplay(WinList) $AllWindowsCount = $AllWindows[0][0] MsgBox($MB_OK, "WINDOW COUNT", "There are " & $AllWindowsCount & " Windows") ReDim $WindowsDupe[(UBound($AllWindows)) + 1] _ArrayColInsert($WindowsDupe, 1) ; add the second dimension $TitleMatchCount = 0 For $i = 1 To $AllWindowsCount If StringInStr($AllWindows[$i][0], $titlematch) <> 0 Then $TitleMatchCount += 1 $WindowsDupe[$i][0] = $AllWindows[$i][0] ; copy this HI window's title $WindowsDupe[$i][1] = $AllWindows[$i][1] ; copy this HI window's handle _ArrayDisplay($WindowsDupe) ConsoleWrite(@CRLF & @CRLF & "Idx = " & $i & " Title: " & $WindowsDupe[$i][0] & "Hndl: " & $WindowsDupe[$i][1] & @CRLF) EndIf Next ;$WindowsDupe[0][0] = $TitleMatchCount _ArrayDisplay($WindowsDupe) Return $WindowsDupe ; return a list of all windows EndFunc ;==>FindAllWindows Func _Main() Local $wHnd Local $hiWindowList Local $WindowCount Local $WindowList $WindowList = FindAllWindows("Untitled - Notepad") _ArrayDisplay($WindowList) MsgBox($MB_OK, "AFTER RETURN", "RETURNED FROM FINDALLWINDOWS()") EndFunc ;==>_Main