I am not sure if this is the best way of doing it but thanks to this https://autohotkey.com/board/topic/88278-help-to-close-and-open-a-program-at-a-specific-time/?p=560220 I found the sleeptill functionhttps://autohotkey.com/board/topic/51576-sleep-until-time/. So have replaced all my tasks that are running daily.
I would like now to replace my tasks that are running only on specified days ex: every monday, wednesday and friday at 8am, 11am and 2pm.
I am not sure what's the best way of doing.
I call my tasks like this :
Code: Select all
Loop
{
SleepTill(1100) ;wait till 11 am
Run ...
SleepTill(1610) ;wait till 4:10 pm
Run ...
}
Code: Select all
Loop
{
SleepTill(1,3,5, 1610) ;run at 4:10 pm only monday(1), wednesday (3) and friday(5)
Run ...
}
Here is the sleepTill function
Code: Select all
SleepTill(Time) {
ST_Hour:=SubStr(Time, 1 ,2)
ST_Min:=SubStr(Time, 3 ,2)
ST_Sec:=(SubStr(Time, 5 ,2)<>"" ? SubStr(Time, 5 ,2) : "00")
STime:=(((ST_Hour-A_Hour)*60+(ST_Min-A_Min))*60+(ST_Sec-A_Sec))*1000
STime:=STime<0 ? STime+86400000 : STime
Sleep %STime%
Return % A_Hour ":" A_Min
}
//autohotkey.com/board/topic/51576-sleep-until-time/?p=322568