testtest 0 Posted February 3, 2011 (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 November 30, 2017 by testtest Share this post Link to post Share on other sites
jvanegmond 306 Posted February 3, 2011 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 github.com/jvanegmond Share this post Link to post Share on other sites
testtest 0 Posted February 3, 2011 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
jvanegmond 306 Posted February 3, 2011 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. github.com/jvanegmond Share this post Link to post Share on other sites
Varian 8 Posted February 3, 2011 (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 February 3, 2011 by Varian Share this post Link to post Share on other sites
testtest 0 Posted February 3, 2011 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
Varian 8 Posted February 3, 2011 (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 loopLook up Edited February 3, 2011 by Varian Share this post Link to post Share on other sites
testtest 0 Posted February 3, 2011 Thanks now it's working! Share this post Link to post Share on other sites