Jump to content

timeout shorter than 1 s


 Share

Recommended Posts

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
Link to comment
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
Link to comment
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 :/

Link to comment
Share on other sites

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