Jump to content

Recommended Posts

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
Posted

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
Posted

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 :/

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

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
×
×
  • Create New...