Jump to content

Wait For Multiple Windows With Only Partially Known Title


Recommended Posts

Hi,

i'm trying to write a script that waits for windows to come up and handles them.

At the moment, this is my code:

Opt("WinTitleMatchMode", 2)
;wait for a window containing "Untitled"
WinWaitActive("Untitled")
$title = WinGetTitle("Untitled")
... do something...

This only works with one window. I need to handle multiple windows which contain my searchstring in their titles, so something returning a list of titles matching my search would be perfect. Any ideas?

Thanks,

Kevin.

Link to comment
Share on other sites

This is the nicest solution to this if you ask me. Have not tried it yet thought.

The Latest AutoIt Beta can wait for more then 2 windows by using regular expressions.

Here is a Demo

Opt('WinTitleMatchMode', 4)
Switch Random(1, 3, 1)
    Case 1
        RunWait('explorer "' & @ProgramFilesDir & '"')
    Case 2
        RunWait('explorer "' & @WindowsDir & '"')
    Case 3
        RunWait('explorer "' & @SystemDir & '"')
EndSwitch
WinWait('regexp=(?i)program files|windows|system32', '', 1)
$title = WinGetTitle('regexp=(?i)program files|windows|system32')
Sleep(500)
WinClose($title)
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...