MyEarth Posted May 22, 2015 Share Posted May 22, 2015 Hello. I need to replace a Sleep() with something similar but without Sleep() all the While-WEnd but just the If-EndIfAn example:HotKeySet("{ESC}", "ESC")HotKeySet("{F1}", "Var")Local $iVar1 = 0, $iVar2 = 0While 1 ; other things Sleep(10) If $iVar1 = $iVar2 Then Sleep(1000) ; replace this! ConsoleWrite("$iVar1 = $iVar2" & @CR) EndIfWEndFunc Var() $iVar2 = 1 ; stop the ConsoleWriteEndFuncFunc ESC() ExitEndFuncAs you can see i have a main Sleep of 10ms ( in the script is done by GUIGetMsg() ) and another Sleep if a condition found, i want to replace that. I have think to use TimerInt - TimerDiff but for what i have understand i need to put TimerInt OUTSIDE the loop. No i don't want to have two different loop.Thanks for the help Link to comment Share on other sites More sharing options...
Developers Jos Posted May 22, 2015 Developers Share Posted May 22, 2015 Untested but should show an options:ocal $iVar1 = 0, $iVar2 = 0, $itimer = 0 While 1 ; other things Sleep(10) If $iVar1 = $iVar2 Then $itimer = TimerInit() EndIf If $itimer <> 0 and TimerDiff($itimer) >= 1000 Then ConsoleWrite("$iVar1 = $iVar2" & @CR) $itimer = 0 EndIf WEndJos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
MyEarth Posted May 22, 2015 Author Share Posted May 22, 2015 Thanks Yoda-Jos but not work, i don't see any ConsoleWrite. Probably because the $itimer is reset every 10ms and never goes to 1000ms Link to comment Share on other sites More sharing options...
Developers Jos Posted May 22, 2015 Developers Share Posted May 22, 2015 Then simply ensure that it isn't reset in each loop by adding a test like:If $iVar1 = $iVar2 and $iTimer = 0 ThenJos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. 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