Jump to content

WinWaitActive VS WinActivate


Recommended Posts

In my code I'm doing a lot of things like:

$r = WinWaitActive ($ShipmentOption_Title, "", 1)

If ($r == 1 And $CanelIfFound ==true) THEN

ControlClick ($ShipmentOption_Title, "", $ShipmentOption_CancelBtn) ;Click Cancel button

Trying to make my scripts run faster and with less waits I changed these functions to look like:

$r = WinActivate($ShipmentOption_Title, "")

If ($r == 1 And $CanelIfFound ==true) THEN

ControlClick ($ShipmentOption_Title, "", $ShipmentOption_CancelBtn) ;Click Cancel button

I did this in about 6 or 7 spots and then reran my tests again and compared times. I was surprised to see that the running time was increased by about 20 seconds. Can anyone explain why this happens? Is there a built in wait on the WinActivate's?

Thanks you in advance for your responses,

Programit

What I'm using AutoIt for: I was hired as QA to write automated tests for our software. So I macro any possible situation/process a user could get themselves into, and then check to see that the outcome is what I expect.
Link to comment
Share on other sites

> Is there a built in wait on the WinActivate's?

WinWaitDelay

Alters how long a script should briefly pause after a successful window-related operation.

Time in milliseconds to pause (default=250).

try adding...

Opt("WinWaitDelay", 1)

...near the top of your code

edit: that does not explain your 20 second increase - it just answers your question

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

It should be this way:

WinActivate($ShipmentOption_Title, "")
$r = WinWaitActive ($ShipmentOption_Title, "")
If ($r == 1 And $CanelIfFound ==true) THEN 
ControlClick ($ShipmentOption_Title, "", $ShipmentOption_CancelBtn);Click Cancel button
Is this not going to wait once for the Winactivate and once for the WinWaitActive? I am trying to remove all waits. When this code gets executed the error/window has already popped up and I just need to fly through a bunch of 'if' statements to see which error has popped up and then handle it.
What I'm using AutoIt for: I was hired as QA to write automated tests for our software. So I macro any possible situation/process a user could get themselves into, and then check to see that the outcome is what I expect.
Link to comment
Share on other sites

Is this not going to wait once for the Winactivate and once for the WinWaitActive? I am trying to remove all waits. When this code gets executed the error/window has already popped up and I just need to fly through a bunch of 'if' statements to see which error has popped up and then handle it.

Neither of them really "wait" if the window already exist. This simply tells the script to set the focus and activate that particular window. WinWaitActivate waits for that window to appear and then activates it. The time out is if for somereason that window never appears.

The reason that Zedna tells you to use both WinActivate and WinWaitActive is that it can time to activate a window. By humans perception activating a window is instantaneous however it does time a few miliseconds for a computer to complete the task. However if you script tries to do something with the window before it is active it could mess up and maybe crash/stall. So you are simply saying "activate this window, wait until it is activated, and then proceed"

Edited by raj2734
Link to comment
Share on other sites

..... WinWaitActivate waits for that window to appear and then activates it. .....

Incorrect. WinWaitACtive waits until a window becomes active. The window can exist for any length of time and if it is not active then WinWaitActive will just, well, wait.

Zedna says WimActivate so that focus is given to the window. If it does become active, ie if WinActivate succeeded, then WinWaitACtive will detect it becoming active.

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.
Link to comment
Share on other sites

Well.. I did it the way Zedna explains and ODDLY enough, it takes about 15 seconds less time to execute. So.. I add more commands, including ones with a wait, and it executes faster. I don't really understand that, but whatever.

What I'm using AutoIt for: I was hired as QA to write automated tests for our software. So I macro any possible situation/process a user could get themselves into, and then check to see that the outcome is what I expect.
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...