MyEarth 10 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 Share this post Link to post Share on other sites
Jos 2,164 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. Share this post Link to post Share on other sites
MyEarth 10 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 Share this post Link to post Share on other sites
Jos 2,164 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. Share this post Link to post Share on other sites