Jump to content

WinWaitActive timeout behavior?


Recommended Posts

In reading the definition of what WinWaitActive should do, I get the sense that the timeout fires off if the window you are waiting for doesn't become active.

WinWaitActive ( "title", ["text"], [timeout] )

Parameters

title      The title of the window to check.

text      [optional] The text of the window to check.

timeout [optional] Timeout in seconds

Return Value

Success: Returns 1.

Failure: Returns 0 if timeout occurred.

However, in practice, this doesn't appear to be the case. Could someone explain to me the behavior of the timeout in this function?

Here's a simple two lines that you can test this behavior with, this will look for the first window when you launch the Add Printer Wizard in Windows XP. In my test, the WinWaitActive line doesn't actually expire until I bring up the wizard.

WinWaitActive("Add Printer Wizard","",500)

MsgBox(0,"Nope","Didn't find it")

Secondly, I want to have my script look for the window, and after a certain time period, move on to the next line of code if it doesn't (i.e. when it times out).

Any help on these would be greatly appreciated.

[Edit] Clarification of the central question.

Edited by ColoradoDon
Link to post
Share on other sites
  • Administrators

Yes, feeling exceptionally silly.  It works as expected.  Sorry for taking your time.

[Edit] I understand why I was confused.  Got mixed up between the seconds that WinWaitActive() uses and the milliseconds that Sleep() uses.

Happens all the time. Doesn't mean I've learnt to resist the urge to ask the "are you sure" question though :lmao:
Link to post
Share on other sites

Happens all the time.  Doesn't mean I've learnt to resist the urge to ask the "are you sure" question though  :lmao:

<{POST_SNAPBACK}>

To tell the honest truth, I'd rather have a timer function that waits based on a suffix you put after the number, For example:
WinWaitActive($title,$text,500 ms);- miliseconds
WinWaitActive($title,$text,500 s) ;- seconds
WinWaitActive($title,$text,500 m);- minutes
WinWaitActive($title,$text,500 h) ;- hours

But I'm sure it'd be a bugger to code.

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Link to post
Share on other sites
  • 15 years later...
1 hour ago, KurtGP said:

This post is still relevant in 2020, because I made the same new user first time assumption that all time was in milliseconds, while WinWait is in seconds, lol.

First post and NOT relevant.  Good job.  Oh, sorry welcome to AutoIt forum...

Link to post
Share on other sites
1 hour ago, KurtGP said:

This post is still relevant in 2020, because I made the same new user first time assumption that all time was in milliseconds, while WinWait is in seconds, lol.

The OP is still relevant - the fact that it is still relevant may not be.
 


 

Code hard, but don’t hard code...

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...