Jump to content

Loop Through Window Titles


Webs
 Share

Recommended Posts

I tried searching but couldn't find much help for this...

Basically what I'm trying to do is loop through the 11 Windows I have open on my system by title. Just getting this small part functioning is important as it will be part of a larger script. I'm just going crazy trying to figure out what I'm doing wrong. Am I using one of the functions wrong? Or what am I missing?

Any help would be greatly appreciatly!

While 1
    $WindowTitle = WinGetTitle( "" , "" )
    Select
        Case $WindowTitle = ( "File Download" )
            MsgBox ( 1, "Window Title - Found it", $WindowTitle)
            Exit
        Case Else
            MsgBox ( 1, "Window Title - Not it", $WindowTitle)
    EndSelect
WEnd
MsgBox ( 1, "Out of Loop", "Oh noes")
Exit
Edited by Webs
Link to comment
Share on other sites

Voilá,

Dim $arTitles = WinList()
For $i = 1 to $arTitles[0][0]
    If $arTitles[$i][0] = "File Download" Then
        MsgBox ( 1, "Window Title - Found it", $arTitles[$i][0])
        Exit
    Else
        ConsoleWrite("!> " & $arTitles[$i][0] & " is not it :(" & @CRLF)
    EndIf
Next
MsgBox (1, "Out of Loop", "Oh noes")
Link to comment
Share on other sites

Thanks for the help James, your code worked perfectly! If I understand things correctly, my code needs an array that has all the titles in it, otherwise the msgbox will only display one title which will be the first one it comes across.

Link to comment
Share on other sites

Thanks for the help James, your code worked perfectly! If I understand things correctly, my code needs an array that has all the titles in it, otherwise the msgbox will only display one title which will be the first one it comes across.

WinList puts all of the window titles (as of calling) into a two dimensional array. And the way the code I showed you, will also just display one message box because of the Exit command beneath it ;)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...