#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. SendMode Input ; Recommended for new scripts due to its superior speed and reliability. SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. #SingleInstance, Force #Persistent Times= ;make sure they are in order earliest to latest unless you want to add a sort command ( 0700|^!+{F1} 0800|^!+{F2} 0900|^!+{F3} 1100|^!+{F4} 1200|^!+{F5} 1400|^!+{F6} 1500|^!+{F7} 1600|^!+{F8} 1700|^!+{F9} 1720|^!+{F10} 1740|^!+{F11} 1800|^!+{F12} 1830|^!#{F1} 1900|^!#{F2} 1930|^!#{F3} 2000|^!#{F4} 2100|^!#{F5} 2300|^!#{F6} ) OnExit, Exit IfNotExist, Time.txt { FileAppend, % Times, Time.txt loop, read, Time.txt Lines := A_Index Loop, Parse, Times, `n, `r ; Finds the closest time in tTime to the current time { StringSplit, string, A_LoopField, | Difference := MTime() - string1 If Difference "" ? SubStr(Time, 5 ,2) : "00") STime:=(((ST_Hour-A_Hour)*60+(ST_Min-A_Min))*60+(ST_Sec-A_Sec))*1000 STime:=STime0 ? STime+86400000 : STime Sleep %STime% Return % A_Hour ":" A_Min }