programit Posted October 14, 2008 Posted October 14, 2008 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 buttonTrying 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 buttonI 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.
herewasplato Posted October 14, 2008 Posted October 14, 2008 (edited) > 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 October 14, 2008 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size]
Cdma1X Posted October 14, 2008 Posted October 14, 2008 Is there a built in wait on the WinActivate's? in WinWaitActive() and WinWait() there is a flag option to wait for the window to be active. WinWaitActive("Window", "",10) ; this will wait for 10sec if the window does not exists
Zedna Posted October 14, 2008 Posted October 14, 2008 (edited) 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 Edited October 14, 2008 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search
programit Posted October 14, 2008 Author Posted October 14, 2008 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.
raj2734 Posted October 14, 2008 Posted October 14, 2008 (edited) 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 October 14, 2008 by raj2734
martin Posted October 14, 2008 Posted October 14, 2008 ..... 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.
programit Posted October 14, 2008 Author Posted October 14, 2008 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now