Scheduled Tasks
_This script allows tasks to be performed at specific times of day, day of the week, day of the month and/or month of the year. It checks the current system time against listed times, when it finds a match it runs the associated task.
#noenv #singleinstance, ignore ;*1 #persistent ;*2 setbatchlines, 10ms ;*3 settimer, emptymem, 600000 ;*4 settimer, time, 500 ;*5 return ;*6 time: { formattime, time, , hh:mm:ss tt ;*7 formattime, weekday, , dddd ;*8 formattime, monthday, , dd ;*9 formattime, month, , MM ;*10 if (time = "05:47:18 pm") ;*11 { goto, task1 } if (time = "10:00:00 am" && weekday = "sunday") ;*12 { goto, task2 } if (time = "02:00:00 pm" && monthday = "01") ;*13 { goto, task3 } if (time = "08:00:00 am" && monthday = "25" && month = "12") ;*14 { goto, task4 } } return task1: { msgbox, It is now %time%. } return task2: { msgbox, It is now %time% on %weekday%. } return task3: { msgbox, It is now %time% on the %monthday%st day of the month. } return task4: { msgbox, Merry Christmas! } return emptymem: ;*15 { dllcall("psapi.dll\EmptyWorkingSet", "UInt", -1) } return /* 1 Prevents multiple instances of the script. 2 Tells the script to continue running permanently. 3 Pauses the script for 10ms every 10ms. minimizes resource use. 4 Calls emptymem subroutine every 10 minutes. 5 Check current date and time every half second. 6 Designates the end of the auto-execute section. 7 Provides current system time in the specified format. 8 Provides current day of the week in the specified format. 9 Provides current day of the month in the specified format. 10 Provides current month in the specified format. 11 Runs task1 subroutine every day at specified time. 12 Runs task2 subroutine at specified time on specified day of the week. 13 Runs task3 subroutine at specified time on the first day of each month. 14 Runs task3 subroutine at specified time only on the 25th of december. 15 Reduces ram used by the script. */ |
_It should be noted that this script will only run a task if the script is running at the specified time. The script works by comparing literal strings, and as such is incapable of determining if a date or time is near or has passed.