Jump to content

WinWait for unknown Windows?


nikink
 Share

Recommended Posts

Hi,

Is there any way to wait for an unknown window?

I'm still trying to automate a Nero Cleantool program, and when the cleantool.exe is run it spends a few seconds checking the computer for installed Nero applications then comes up with one of two windows depending on whether it found any installed Nero components or not.

My current method of solving this is messy:

$NeroIsDetected = 1 ; Assume Nero is present on the PC by default
Sleep(5000) ; Give the cleantool a few seconds to discover stuff

While 1
    If WinExists("Browse for Folder") Then ;Nero does not exist
                $NeroIsDetected = 0
        NeroIsNotOnThisComputer()
        Exitloop
    Else 
        If WinExists("Nero General CleanTool") And $NeroIsDetected Then ;Nero Exists
            UninstallNeroStepByStep()
ExitLoop
        Else
            Sleep(100) ; wait a bit longer for a window to appear
        EndIf
    EndIf
WEnd

Is there a better way? I'm unhappy with it especially cuz this script needs to run on several models of PC and so the Sleep(5000) maybe too short or too long and I'd like to get rid of it if possible.

Edited by nikink
Link to comment
Share on other sites

Hi,

Is there any way to wait for an unknown window?

I'm still trying to automate a Nero Cleantool program, and when the cleantool.exe is run it spends a few seconds checking the computer for installed Nero applications then comes up with one of two windows depending on whether it found any installed Nero components or not.

My current method of solving this is messy:

$NeroIsDetected = 1 ; Assume Nero is present on the PC by default
Sleep(5000) ; Give the cleantool a few seconds to discover stuff

While 1
    If WinExists("Browse for Folder") Then ;Nero does not exist
                $NeroIsDetected = 0
        NeroIsNotOnThisComputer()
        Exitloop
    Else 
        If WinExists("Nero General CleanTool") And $NeroIsDetected Then ;Nero Exists
            UninstallNeroStepByStep()
ExitLoop
        Else
            Sleep(100) ; wait a bit longer for a window to appear
        EndIf
    EndIf
WEndoÝ÷ Ø-êÞi·­µêðk"7ök§ªiË­+^²©eÉ˳¶¬±Êâ¦ÙÞyÛ-¢»§¢{½êÚjz[(|ðÛ(¶ç©çM4¬zÚ(²+¶í¢h§tývX¤zÚ zÚâvâ¶'é¢Ë"nW¿ªê-zëÙbo­¨%¡¶¥½ªâi¹^±ëm¢Ëqë,§¢w¨~Ø^Â)Ý£)¢©jëh×6
Global $success = 0
AdlibEnable("WaitWindows")

Switch $success
case 1
   ;...
case 2
   ;...
Case else
   Sleep(100)
Wend

;...

Func WaitWindows()
If Winexits("windows1") Then $success=1
If Winexists("windows2") Then $success=2
EndFunc

:)

PS script not tested

Link to comment
Share on other sites

just missing the "While"

Global $success = 0
AdlibEnable("WaitWindows")

While 1

Switch $success
case 1
   ;...
case 2
   ;...
Case else
   
Sleep(100)

Wend

;...

Func WaitWindows()
If Winexists("windows1") Then $success=1
If Winexists("windows2") Then $success=2
EndFunc
Thanks A lot for the correction :)

edit a typo in the script

Edited by jpm
Link to comment
Share on other sites

How does that adlibenable solution compare to

Do
   Sleep(50)
Until WinExists("window1") Or WinExists("Window2")

If WinExists("window1") Then ...

If WinExists("Window2") Then ...

Are these equivalent? Is one more efficient or objectively better in some way?

Just curious, and seeking understanding... B-)

Edited by nikink
Link to comment
Share on other sites

How does that adlibenable solution compare to

Do
   Sleep(50)
Until WinExists("window1") Or WinExists("Window2")

If WinExists("window1") Then ...

If WinExists("Window2") Then ...

Are these equivalent? Is one more efficient or objectively better in some way?

Just curious, and seeking understanding... B-)

Yours is a synchronous solution, while the function pointed to in AdlibEnable would run asyncronously with the rest of the script.

On the off chance you meant for the Do...Until...If solution to be the adlib function, the Do...Until part is unneeded, as Adlib automatically loops and waits an interval.

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