testtest Posted February 3, 2011 Share 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 Link to comment Share on other sites More sharing options...
jvanegmond Posted February 3, 2011 Share 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 Link to comment Share on other sites More sharing options...
testtest Posted February 3, 2011 Author Share 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 :/ Link to comment Share on other sites More sharing options...
jvanegmond Posted February 3, 2011 Share 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 Link to comment Share on other sites More sharing options...
Varian Posted February 3, 2011 Share 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 Link to comment Share on other sites More sharing options...
testtest Posted February 3, 2011 Author Share 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 Link to comment Share on other sites More sharing options...
Varian Posted February 3, 2011 Share 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 Link to comment Share on other sites More sharing options...
testtest Posted February 3, 2011 Author Share Posted February 3, 2011 Thanks now it's working! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now