Shastaman Posted April 24, 2009 Posted April 24, 2009 I see how to set a delay after a successful window operation (WinWaitDelay), but how do you set the frequency at which it polls for the window up to the timeout value?
martin Posted April 24, 2009 Posted April 24, 2009 I see how to set a delay after a successful window operation (WinWaitDelay), but how do you set the frequency at which it polls for the window up to the timeout value?I don't think you can but you could make your own loop with a sleep to control how often you check something. 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.
herewasplato Posted April 25, 2009 Posted April 25, 2009 I see how to set a delay after a successful window operation (WinWaitDelay), but how do you set the frequency at which it polls for the window up to the timeout value?I'm not sure that I understand what you are after. Could you provide a small sample script where you would use such a parameter? [size="1"][font="Arial"].[u].[/u][/font][/size]
Shastaman Posted April 29, 2009 Author Posted April 29, 2009 I'm not sure that I understand what you are after. Could you provide a small sample script where you would use such a parameter?I'm using AutoIt to run application tasks and trying to measure the time to complete. The frequency at which it checks for the window to exist/not exist will determine the precision you are able to attain in measuring the operation. For example, if it polled once every second, then the window could appear from right after the last poll up to 1 second before polling again. So my timer would add on up to 1 second in additional time beyond the actual completion time.Depending on the length of the operation, determines whether this is enough precision. A long operation of many seconds might not matter for comparison but a short operation would be overwhelmed by the tolerance of the precision.
Shastaman Posted April 29, 2009 Author Posted April 29, 2009 I'm using AutoIt to run application tasks and trying to measure the time to complete. The frequency at which it checks for the window to exist/not exist will determine the precision you are able to attain in measuring the operation. For example, if it polled once every second, then the window could appear from right after the last poll up to 1 second before polling again. So my timer would add on up to 1 second in additional time beyond the actual completion time.Depending on the length of the operation, determines whether this is enough precision. A long operation of many seconds might not matter for comparison but a short operation would be overwhelmed by the tolerance of the precision.Or does it not poll at all but do an asynchronous callback or something?
WideBoyDixon Posted April 29, 2009 Posted April 29, 2009 Why not roll your own? While Not WinExists("My Window") Sleep(xxx) Wend WBD [center]Wide by name, Wide by nature and Wide by girth[u]Scripts[/u]{Hot Folders} {Screen Calipers} {Screen Crosshairs} {Cross-Process Subclassing} {GDI+ Clock} {ASCII Art Signatures}{Another GDI+ Clock} {Desktop Goldfish} {Game of Life} {3D Pie Chart} {Stock Tracker}[u]UDFs[/u]{_FileReplaceText} {_ArrayCompare} {_ToBase}~ My Scripts On Google Code ~[/center]
martin Posted April 29, 2009 Posted April 29, 2009 Why not roll your own? While Not WinExists("My Window") Sleep(xxx) Wend WBD Exactly. (post #2) 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.
Shastaman Posted April 29, 2009 Author Posted April 29, 2009 Exactly. (post #2)Yes I understand I could but I want to know what WinWait does since I have pre-existing code utilizing that. Additionally, if I roll my own, I'm responsible for determining the polling frequency which doesn't interfere with measurement activity.At this point, it seems certain that I can't configure it, but I'd like to know so I can judge the prospective precision.It seems to boil down to the method used for WinWait timeout type funcs. I don't need specifics of the mechanism but the general method.
herewasplato Posted April 29, 2009 Posted April 29, 2009 ... but how do you set the frequency ...Thanks for your explanation.You said that you did not wish to "roll your own" (winexists loop) due to data gathered by exiting code. If you could change/set the polling freq - wouldn't that change the resulting data? Or am I missing something other than sleep :-) [size="1"][font="Arial"].[u].[/u][/font][/size]
Shastaman Posted April 29, 2009 Author Posted April 29, 2009 Yep, I could do it many other ways. So, answer?
herewasplato Posted April 29, 2009 Posted April 29, 2009 There is no way that I know of to change that polling parameter. Maybe a DEV will stop by and comment on your options. [size="1"][font="Arial"].[u].[/u][/font][/size]
GEOSoft Posted April 30, 2009 Posted April 30, 2009 I don't think it will have a bearing on WinWait() but if you try using a different method make sure to read Opt("WinWaitDelay", nnn) = Alters how long a script should briefly pause after a successful window-related operation. Time in milliseconds to pause (default=250). George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
Shastaman Posted April 30, 2009 Author Posted April 30, 2009 I understand I can't change it, but I would like to know what it's already set to.
Developers Jos Posted April 30, 2009 Developers Posted April 30, 2009 (edited) I was under the impression that Opt("WinWaitDelay") is used for all Win????() functions and is set to 250 by default. This simple example waits 10 secs before ending: Opt("WinWaitDelay", 10000) Run("notepad.exe") WinWait("Untitled") Here is a more extensive test to show how the WinWaitDelay influences the script flow : $t = TimerInit() Run("notepad.exe") WinWait("Untitled") ConsoleWrite(TimerDiff($t) & " step_a" & @CRLF) WinClose("Untitled") ConsoleWrite(TimerDiff($t) & " step_b" & @CRLF) WinWaitClose("Untitled") ConsoleWrite(TimerDiff($t) & " step_c" & @CRLF) $t = TimerInit() Opt("WinWaitDelay", 10) Run("notepad.exe") WinWait("Untitled") ConsoleWrite(TimerDiff($t) & " step1a" & @CRLF) WinClose("Untitled") ConsoleWrite(TimerDiff($t) & " step1b" & @CRLF) WinWaitClose("Untitled") ConsoleWrite(TimerDiff($t) & " step1c" & @CRLF) $t = TimerInit() Opt("WinWaitDelay", 1000) Run("notepad.exe") WinWait("Untitled") ConsoleWrite(TimerDiff($t) & " step2a" & @CRLF) WinClose("Untitled") ConsoleWrite(TimerDiff($t) & " step2b" & @CRLF) WinWaitClose("Untitled") ConsoleWrite(TimerDiff($t) & " step2c" & @CRLF) $t = TimerInit() Opt("WinWaitDelay", 4000) Run("notepad.exe") WinWait("Untitled") ConsoleWrite(TimerDiff($t) & " step3a" & @CRLF) WinClose("Untitled") ConsoleWrite(TimerDiff($t) & " step3b" & @CRLF) WinWaitClose("Untitled") ConsoleWrite(TimerDiff($t) & " step3c" & @CRLF) Jos Edited April 30, 2009 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
herewasplato Posted April 30, 2009 Posted April 30, 2009 Let me see if I can restate what the OP is asking.[That might be pretty hard given my lack of sleep and programming knowledge.]seconds00.000001 run notepad00.000002 ; some lag just for AutoIt/OS to00.000003 ; get to the next line of code00.000004 winwait < "loops" (polls/checks) while looking for the window???00.00000500.000006~~~02.000000 ; the window appears~~~02.000294 ; winwait actually detects that the window is there02.000295 ; a delta of 294 microseconds 02.000296 ; we don't care how big the delta is - just that it is known02.000297 ;02.000298 ; WinWaitDelay can be set to 0 but more stable at 1ms02.001299 ; or am I thinking of some other parm ^^^^^^02.00130002.001301 ; the OP's timer function goes hereIf this is anywhere near right...00.000004 winwait < "loops" (polls/checks) while looking for the window???...then what is the hard coded (built in) delay in that loop?The way that the OP worded his questions - he probably has a better understanding of how this stuff works than do I. He seems to think that it is the WinWaitDelay function that is polling/looping/looking for the window to come into existence in some kind of tandem with WinWait. Hence the OP asking, "Or does it not poll at all but do an asynchronous callback or something?"I see that Jos updated his post - but I'm going to post this anyway - just for the fun of it. [size="1"][font="Arial"].[u].[/u][/font][/size]
Shastaman Posted April 30, 2009 Author Posted April 30, 2009 Thanks for your extraordinary patience. Let me change how I'm asking my question. Here's what I'm doing: //Start timer $begin = TimerInit() //while the script is running, I manually start Notepad WinWait("Notepad","",30) //Stop timer elapsedTime = TimerDiff($begin) How does the WinWait command work to detect the appearance of the Notepad window? The method will determine my measurement accuracy and answer my question. WinWait has some mechanism to watch for the window to appear. I'm guessing a polling mechanism. If so, then it must check at some regular interval. It has to be less than continuous otherwise the system would spend the whole time checking for the window, and the actual window creation wouldn't have a chance to run. It has to be some balance between checking for the window, and generating the window because, again, taking all the processing time with checking for the window will prevent the actual window creation process from getting time to perform. Further, the interval will determine the accuracy of the measurements because some portion of the interval will inevitably be added to the elapsed time. 00.000001 start timer 00.000004 winwait starts - first window check - window not found yet 00.000005 wait interval 00.000006 ~~~ 02.000000 ; the window appears ~~~ 02.000294 ; winwait checks again, actually detects that the window is there 02.000295 ; end timer In our example, the measured time will be between 00.000001 and 02.000295. However, the actual time to complete the operation was 00.000001 -> 02.000000. The time added by waiting for the interval to perform the next check is 02.000000 -> 02.000294. If I'm measuring two second long operations, but I only check for the window every 1 second, then I could add another whole second to my measurement, increasing the operation time by 150%. I want to know first, what is the checking for window method (poll or something else), and then , if polling, what that interval is.
Shastaman Posted April 30, 2009 Author Posted April 30, 2009 WinWaitDelay doesn't enter into this as it just adds an additional delay after completion. I must set that delay to zero to get accurate measurements otherwise every meausrement will have a constant added to it.
Developers Jos Posted April 30, 2009 Developers Posted April 30, 2009 Have you read my posts and tested with the provide scriptlet? This will demonstrate what the internal polling and timing is. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Shastaman Posted April 30, 2009 Author Posted April 30, 2009 Have you read my posts and tested with the provide scriptlet?This will demonstrate what the internal polling and timing is.JosI understand WInWaitDelay clearly. It merely adds a constant time after a successful window find command. I definitely don't want to use that.I don't see that your script exposes the polling frequency. I think it is impossible to use the script to measure the polling frequency because the time measured will include the use of the mechanism which includes the polling frequency. Step a measures starting the application and finding the window. Step b closes the window and measures the total time up to that point. Step c waits for that window to close and measures the total time up to that point.I thought someone would know the implementation and could provide that information. I'm a little surprised it's not a well known quantity since this tool is used for automating operations which could be measured. Perhaps I can determine it by generating events at specific times myself and comparing to the detection time from auto IT.
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