Isoraqathedh

AHK time-sensitive loops

May 8th, 2013
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. FormatTime startTime, 20051231020000, HH ; 2005 Dec 31 02:00:00; the actual date does not matter
  2. FormatTime endTime,   20051231160000, HH ; 2005 Dec 31 16:00:00; the actual date does not matter
  3. Loop {
  4.     FormatTime currTime, , HH ; If the second value is blank then it takes the current time
  5.     if (startTime < currTime and currTime < endTime) {
  6.         ; Do your stuff
  7.     }
  8.     Sleep % 30 * 60 * 1000 ; stop execution for 30 mins (can be reduced as needed)
  9. }
  10.  
  11. ; Alternatively, if the "your stuff" needs to repeat:
  12.  
  13. FormatTime startTime, 20051231020000, HH
  14. FormatTime endTime,   20051231160000, HH
  15. Loop {
  16.     FormatTime currTime, , HH
  17.     if (startTime < currTime) {
  18.         Loop {
  19.             ; Do your stuff
  20.             if (currTime > endTime) break
  21.             Sleep 20 * 1000 ; 20 seconds (can be reduced as needed)
  22.         }
  23.     }
  24.     Sleep % 30 * 60 * 1000 ; stop execution for 30 mins (can be reduced as needed)
  25. }
Advertisement
Add Comment
Please, Sign In to add comment