Sign in to follow this  
Followers 0
yougoudai

Waiting for the end of a window

7 posts in this topic

Hi everybody :)

First of all, I apologize for my English, I'm french...

I'm just looking for a simple question : I just want something happens when a specific window does not exist after, for example, 15 seconds.

In fact I have IE window that install some patches, disappears, and reappears again for some new patches... So I rally don't know how AutoIt can detect the window closed after 15 second of non-activities...

I do not have my script here, but I tried to do a infinite loop with a while,

* after a loop with "if" to test if the window exists ("WinExist"),

* if the windows exists, continue the loop

* if the windows does not exist, wait 15 seconds and test again

...

but As soon the window disappears, autoit do not wait and told me that the windows is gone, and the window reappears...

Can you please help me ?

Kind regards,

Share this post


Link to post
Share on other sites



First of all, your English is quite all right(if I as a dutch person can judge).

On your question: It is quite dangerous to look only for the existence of a window in these kind of cases. It would probably be more safe to first get the process ID and watch that one. If you like to go on this way, I'd better investigate the problem if you show the important parts of your script. Note that the sleep command has milliseconds as input, this can result in the described behaviour.

If the window pops-up, you can also use the winwaitactive command, where you can specify the timeout (in seconds). I hope this will help you, else please give some more information


In the beginning there was nothing and then even that exploded - anonymous

Share this post


Link to post
Share on other sites

Hi everybody :)

First of all, I apologize for my English, I'm french...

I'm just looking for a simple question : I just want something happens when a specific window does not exist after, for example, 15 seconds.

In fact I have IE window that install some patches, disappears, and reappears again for some new patches... So I rally don't know how AutoIt can detect the window closed after 15 second of non-activities...

I do not have my script here, but I tried to do a infinite loop with a while,

* after a loop with "if" to test if the window exists ("WinExist"),

* if the windows exists, continue the loop

* if the windows does not exist, wait 15 seconds and test again

...

but As soon the window disappears, autoit do not wait and told me that the windows is gone, and the window reappears...

Can you please help me ?

Kind regards,

If, as DMEE says, using the title is not a problem then something like this might work.

WinWait($titlehere, 300);wait up to 5 minutes for window
;window has appeared or > 5 minutes
$tt = TimerInit()

While TimerDiff($tt) < 20000;allow 20 sec for window to come back
    If WinExists($titlehere) Then
        While WinExists($titlehere)
            Sleep(5000)
        WEnd
        $tt = TimerInit()
    EndIf
WEnd
;window has not existed for 20 seconds or never appeared in the 5 min period

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Thank you very much for your answers guys, you're great ! I cannot test right now the scripts but I'll as soon I can.

I just thought too about that code :

While WinExists("titlehere")
    
    Sleep("20000")
    ContinueLoop

Wend
    
; Normally the windows should be not active after 20 seconds, so i can execute the code...


MsgBox(4096,"YEAH","Done !")

What do you think about it ?

Share this post


Link to post
Share on other sites

While WinExists("titlehere") = 1
    
    Sleep("20000")
    ContinueLoop

Wend
    
; Normally the windows should be not active after 20 seconds, so i can execute the code...


MsgBox(4096,"YEAH","Done !")

That's better.


[center]It's a question of mind over matter, if I don't mind, it doesn't matter.[/center]

Share this post


Link to post
Share on other sites

Ok, thanks System24, but the "=1" is not optional ?

Share this post


Link to post
Share on other sites

While WinExists("titlehere") = 1
    
    Sleep("20000")
    ContinueLoop

Wend
    
; Normally the windows should be not active after 20 seconds, so i can execute the code...


MsgBox(4096,"YEAH","Done !")

That's better.

How is it better?

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

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