Jump to content

WinwWait for more than one window


diesel
 Share

Recommended Posts

Is there a way to use WinWait to look for more than one window? I have a program that crashes sometimes while doing some processing. The normal behaviour is to wait for the window with the processing completed message. Sometimes the program crashes during this processing step and a different window is displayed. How can I detect the window with the error message if it occurs?

I've considered using the timeout option of WinWait to give up after a set time, but I'm wondering if there is another way to do this? Also, the script and program run without having focus or being the active window. I would like to maintain this behaiviour if possible.

Thanks,

David

Link to comment
Share on other sites

Use If-Else statements?

If WinWait("Window1") AND WinWait("Window2") Then ...

The speed of sound is defined by the distance from door to computer divided by the time interval needed to close the media player and pull up your pants when your mom shouts "OH MY GOD WHAT ARE YOU DOING!!!"

Link to comment
Share on other sites

I normally think of using Adlib for unexpected events. Or you could use a loop with WinExists.

Example of Adlib working.

Opt('WinTitleMatchMode', 2)

; Unexpected window
Run('explorer ' & @ProgramFilesDir)

; Start Adlib (using very large time just for example)
AdlibEnable('AdlibFunction', 10000)

MsgBox(4096, '', 'WinWait is following this message in 2 second', 2)

; Waiting for this window
WinWait('NoWindow')

AdlibDisable()

Func AdlibFunction()
    If WinExists('Program Files') Then
        MsgBox(4096, 'Unexpected window found', 'Closing Unexpected "Program Files" window', 2)
        WinClose('Program Files')
        Exit
    EndIf
EndFunc
Link to comment
Share on other sites

I normally think of using Adlib for unexpected events. Or you could use a loop with WinExists.

Thanks MHz! AdlibEnable is going to do the trick for me.

Shibuya: I tried using an if-else structure as well as an if statement with an OR condition. Only the first condition seems to be recognized in both cases. Thanks for your suggestion.

David

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...