frank10 Posted October 5, 2010 Share Posted October 5, 2010 I have a script with a while loop every 100ms, but I could change the interval in the future. I want to make some operations only once at a specific time: 11:00:00, 11:40:00 etc. So I wrote: $interval = 100 while 1 if @Hour = 11 and @MIN = 00 And @SEC = 00 then ;make my operation EndIf if @Hour = 11 and @MIN = 40 And @SEC = 00 then ;make my operation EndIf Sleep($interval) wend But obviously it fires 10 times. So, how can I avoid this? Making a @msec control? or making a boolean variable changing its state after a second? Is there a simpler-neater solution? Link to comment Share on other sites More sharing options...
wakillon Posted October 5, 2010 Share Posted October 5, 2010 (edited) I have a script with a while loop every 100ms, but I could change the interval in the future. I want to make some operations only once at a specific time: 11:00:00, 11:40:00 etc. So I wrote: $interval = 100 while 1 if @Hour = 11 and @MIN = 00 And @SEC = 00 then ;make my operation EndIf if @Hour = 11 and @MIN = 40 And @SEC = 00 then ;make my operation EndIf Sleep($interval) wend But obviously it fires 10 times. So, how can I avoid this? Making a @msec control? or making a boolean variable changing its state after a second? Is there a simpler-neater solution? It's normal the sleep time is 100 ! ( 10 fire * 100 ms = 1 Second ) Add a sleep ( 1000 ) before ;make my operation ! Edited October 5, 2010 by wakillon AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
JohnOne Posted October 5, 2010 Share Posted October 5, 2010 There are a number of ways, you could add a flag $bFlag = True $interval = 100 while 1 if @Hour = 11 and @MIN = 00 And @SEC = 00 And $bflag = True then $bflag = False ;make my operation EndIf If @SEC <> 00 Then $bflag = False EndIf Sleep($interval) wend AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Tvern Posted October 5, 2010 Share Posted October 5, 2010 There are a number of ways, you could add a flag $bFlag = True $interval = 100 while 1 if @Hour = 11 and @MIN = 00 And @SEC = 00 And $bflag = True then $bflag = False ;make my operation EndIf If @SEC <> 00 Then $bflag = True EndIf Sleep($interval) wend Fixed? Link to comment Share on other sites More sharing options...
frank10 Posted October 5, 2010 Author Share Posted October 5, 2010 (edited) Thnk you, yes, with boolean. I changed a bit like this: $interval = 100 while 1 if @Hour = 13 and @MIN = 20 And @SEC = 00 and $bflag then $bflag = False ;make EndIf if @Hour = 13 and @MIN = 21 And @SEC = 00 and $bflag then $bflag = False ;make EndIf If @SEC > 00 Then $bflag = true Sleep($interval) Wend So I use the flag for every timer check 00 sec. Out of curiosity, which other solution other than @msec? Edited October 5, 2010 by frank10 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