Sign in to follow this  
Followers 0
AlexB

Using WinWait() and WinWaitActive() functions

3 posts in this topic

Hi All

I'm trying to automate an external application. Sometimes, I need

to reactivate the window before I use its controls.

I can't say beforehand, how much time this operation (activation) requires,

so I use WinWaitActive() call. I WinWait() before that, to make sure it exists.

On some systems I use, it causes the script execution to pause indefinitely. So

the questions are:

1. How do AutoIt manages these 2 functions? By definition it pauses script until

some even becomes true (such as window exists or window becomes active). What

if the window is already active, and this function does never return? It seems to be the

exact symptom I experience. Can I definitely be sure that window is active and that this

function will not get into an infinite loop?

2. How can I do this without pausing the script at all? I don't know the timing constraints on the system

that this will run on, so I need more generic way of making sure that window is active, but on

the terms of the system it runs on - longer on slow systems, faster on fast systems. I want it

to work in 100% of all possible system configurations. For now, it seems that Wait() functions

do the work on some systems, and get stuck on other.

Thanks.

Share this post


Link to post
Share on other sites



If your window is active already then WinWaitActive() returns immediatelly

so your logic should be OK.

Show your script or related code snippet to see where is your problem.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

If your window is active already then WinWaitActive() returns immediatelly

so your logic should be OK.

Show your script or related code snippet to see where is your problem.

Zedna:

I wrapped it in my own function ActivateWindow() :

Func ActivateWindow($window)
    
    WinWait($window)
    WinActivate($window)
    WinWaitActive($window)
    
EndFunc;==>WinAct

On 2 native systems and 5 virtual PC systems it works fine under various load schemes.

On 1 the most important system, the script pauses in different places, and this code seems

to be the reason for that.

I need to find a way to do this conceptually, but without pausing.

Thanks.

Edited by AlexB

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