Sign in to follow this  
Followers 0
testtest

timeout shorter than 1 s

8 posts in this topic

#1 ·  Posted (edited)

Hallo!

Often the timeout is espressed in second, how can I make it shorter, e.g. 0.5 second?

This is my example:

$s=0

while $s=0

Send("{ENTER}")

$s = WinWaitClose("Save Image", "",1)

WEnd

Thanks

Edited by testtest

Share this post


Link to post
Share on other sites



WinWaitClose is a very simple function that you can recreate with a few lines of code. The benefit of this is that you get more control over what happens on the inside. I haven't tested myself if you can just use WinWaitClose("Save image", "", 0.5).

With the function here you can specify wait time in milliseconds. The window is polled every 10 milliseconds by default: Change this to a reasonable value.

Func _WinWaitCloseMS($title, $text, $timeout, $polltime = 10)
    $start = TimerInit()
    While WinExists($title, $text)
        Sleep($polltime)
        If TimerDiff($start) > $timeout Then
            ExitLoop
        EndIf
    WEnd
EndFunc

Share this post


Link to post
Share on other sites

WinWaitClose is a very simple function that you can recreate with a few lines of code. The benefit of this is that you get more control over what happens on the inside. I haven't tested myself if you can just use WinWaitClose("Save image", "", 0.5).

With the function here you can specify wait time in milliseconds. The window is polled every 10 milliseconds by default: Change this to a reasonable value.

Func _WinWaitCloseMS($title, $text, $timeout, $polltime = 10)
    $start = TimerInit()
    While WinExists($title, $text)
        Sleep($polltime)
        If TimerDiff($start) > $timeout Then
            ExitLoop
        EndIf
    WEnd
EndFunc

Thanks for the help.

However, unfortunately the easy solution WinWaitClose("Save image", "", 0.5) doen't works: the timeout has to be an integer :/

Share this post


Link to post
Share on other sites

I hope I don't have to tell you to use the code I posted. It's really not so much of a stretch to realize that a millisecond is shorter than a second.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

For consistency (to WinWaitClose) you should give the OP the same return values

Func _WinWaitCloseMS($title, $text, $timeout, $polltime = 10)
    $start = TimerInit()
    While WinExists($title, $text)
        Sleep($polltime)
        If TimerDiff($start) >= $timeout Then
            If WinExists($title, $text) Then Return
            ExitLoop
        EndIf
    WEnd
    Return 1
EndFunc
Edited by Varian

Share this post


Link to post
Share on other sites

Yes, I'm tring to use your code but I think it doen's return 0 as the WinWaitClose.

I use it as condition in the while loop

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Yes, I'm tring to use your code but I think it doen's return 0 as the WinWaitClose.

I use it as condition in the while loop

Look up :) Edited by Varian

Share this post


Link to post
Share on other sites

Thanks now it's working!

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