Search code examples
autoit

Check if WinList() contains a certain title


I am listing all open windows using WinList() to get window title and -handle in AutoIt.

I want to check if resulting array contains a specific title. What is the best way to do this? There is no WinList().Contains("TitleName") or something like that.

Local $aList = WinList()    ;Gets a list of Window Titles and IDs

Solution

  • OK, I got it now:

    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