Jump to content
Sign in to follow this  
Shastaman

WinWait polling freq?

Recommended Posts

Shastaman

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?

Share this post


Link to post
Share on other sites
martin

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.

Share this post


Link to post
Share on other sites
Shastaman

Stumped the panel...

Share this post


Link to post
Share on other sites
herewasplato

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]

Share this post


Link to post
Share on other sites
Shastaman

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.

Share this post


Link to post
Share on other sites
Shastaman

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?

Share this post


Link to post
Share on other sites
WideBoyDixon

Why not roll your own?

While Not WinExists("My Window")
    Sleep(xxx)
Wend

WBD

Share this post


Link to post
Share on other sites
martin

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.

Share this post


Link to post
Share on other sites
Shastaman

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.

Share this post


Link to post
Share on other sites
herewasplato

... 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]

Share this post


Link to post
Share on other sites
Shastaman

Yep, I could do it many other ways.

So, answer?

Share this post


Link to post
Share on other sites
herewasplato

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]

Share this post


Link to post
Share on other sites
GEOSoft

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!"

Share this post


Link to post
Share on other sites
Shastaman

I understand I can't change it, but I would like to know what it's already set to.

Share this post


Link to post
Share on other sites
Jos

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 by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
herewasplato

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.]

seconds

00.000001 run notepad

00.000002 ; some lag just for AutoIt/OS to

00.000003 ; get to the next line of code

00.000004 winwait < "loops" (polls/checks) while looking for the window???

00.000005

00.000006

~~~

02.000000 ; the window appears

~~~

02.000294 ; winwait actually detects that the window is there

02.000295 ; a delta of 294 microseconds

02.000296 ; we don't care how big the delta is - just that it is known

02.000297 ;

02.000298 ; WinWaitDelay can be set to 0 but more stable at 1ms

02.001299 ; or am I thinking of some other parm ^^^^^^

02.001300

02.001301 ; the OP's timer function goes here

If 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]

Share this post


Link to post
Share on other sites
Shastaman

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.

Share this post


Link to post
Share on other sites
Shastaman

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.

Share this post


Link to post
Share on other sites
Jos

Have you read my posts and tested with the provide scriptlet?

This will demonstrate what the internal polling and timing is.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Shastaman

Have you read my posts and tested with the provide scriptlet?

This will demonstrate what the internal polling and timing is.

Jos

I 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.

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  

×