Sign in to follow this  
Followers 0
Webs

Loop Through Window Titles

4 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
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")

Share this post


Link to post
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.

Share this post


Link to post
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 ;)

Share this post


Link to post
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
Sign in to follow this  
Followers 0