Page 1 of 1

Create scheduled task to run a macro or program

PostPosted: Wed Apr 03, 2013 6:34 am
by Gintaras
Macro ScheduledTask help     ?
;Creates Windows Task Scheduler task to run a macro or a program.
;You can add one or more schedules of any type to the task.
;Also you can Delete a task.
;Creates/deletes tasks configured for Windows XP/2000/2003, in the same way as QM when you manually create/delete a task using the Properties dialog in QM.
;If after creating a task the schedule is not displayed in QM until it restarts, install QM 2.3.5.3 or later.

;EXAMPLE

#compile "__ScheduledTask"
ScheduledTask x
x.Create("Macro1998")
x.ScheduleOnce("9:00")
x.Save



Currently QM does not display the schedule in the list of macros until restarted. This will be added in next version - QM 2.3.5.3. Will not need to update the code, just install new QM when available.

Re: Create scheduled task to run a macro or program

PostPosted: Wed Apr 03, 2013 3:09 pm
by ldarrambide
install QM 2.3.5.3


Any link? Only 2.3.5.2 in forum from my searches...

Re: Create scheduled task to run a macro or program

PostPosted: Fri Apr 05, 2013 4:55 pm
by Kevin
Gintaras wrote:
This will be added in next version - QM 2.3.5.3. Will not need to update the code, just install new QM when available.

Re: Create scheduled task to run a macro or program

PostPosted: Fri Apr 05, 2013 4:57 pm
by ldarrambide
Thanks, need to change my shades...

Re: Create scheduled task to run a macro or program

PostPosted: Fri Apr 05, 2013 5:00 pm
by Kevin
:lol: np can happen to anyone

Re: Create scheduled task to run a macro or program

PostPosted: Thu Apr 11, 2013 2:59 pm
by pedrotairum
Hey there!

I'm using this function you created because it's really handy but I'm getting a problem. I was able to use it no problem until I got to SetAdvancedScheduleOptions.
My code is simple, goes like this:

#compile "__ScheduledTask"
ScheduledTask T

T.Create("teste")
T.SetAdvancedScheduleOptions("" "" 1 100)
T.Save


After I run it, I get this error:

"Error (RT) in teste2: no schedules added. ?"

Any ideas what I'm doing wrong?

Thanks in advance! :D

Re: Create scheduled task to run a macro or program

PostPosted: Thu Apr 11, 2013 3:20 pm
by Gintaras
From SetAdvancedScheduleOptions help:
Sets options for the last added schedule...

Macro Macro1991     ?
#compile "__ScheduledTask"
ScheduledTask T

T.Create("teste")
T.ScheduleOnceAfter("0:1")
T.SetAdvancedScheduleOptions("" "" 1 100)
T.Save


Re: Create scheduled task to run a macro or program

PostPosted: Tue Jul 18, 2017 8:13 pm
by ssimop
I wonder whether there exists a member function to schedule at odd or even days of the year. Many thanks for any advice.

Re: Create scheduled task to run a macro or program

PostPosted: Tue Jul 18, 2017 8:36 pm
by Gintaras
Try this. Not tested.

Macro Macro2865     ?
#compile "__ScheduledTask"
ScheduledTask x
x.Create("Macro2871")
x.ScheduleDaily("9:00" 2)
x.SetAdvancedScheduleOptions("2017-01-01") ;;02 for even days
x.Save



But maybe better schedule 1 macro, every day. Let it get current day of year and if/else.
Macro Macro2877     ?
DateTime d.FromComputerTime
if d.GetDayOfYear&1
,out 1
else
,out 2


Re: Create scheduled task to run a macro or program

PostPosted: Tue Jul 18, 2017 11:39 pm
by ssimop
Many thanks indeed!