Create scheduled task to run a macro or program

Functions, classes, components, etc. Only high quality content.

Create scheduled task to run a macro or program

Postby Gintaras on Wed Apr 03, 2013 6:34 am

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.
Attachments
ScheduledTask.qml
(11.23 KiB) Downloaded 635 times
Gintaras
Site Admin
 
Posts: 10299
Joined: Thu Dec 19, 2002 7:36 pm
Location: Lithuania

Re: Create scheduled task to run a macro or program

Postby ldarrambide on Wed Apr 03, 2013 3:09 pm

install QM 2.3.5.3


Any link? Only 2.3.5.2 in forum from my searches...
ldarrambide
Active Member
 
Posts: 770
Joined: Wed Feb 25, 2009 1:10 am

Re: Create scheduled task to run a macro or program

Postby Kevin on Fri Apr 05, 2013 4:55 pm

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.
Kevin
Active Member
 
Posts: 359
Joined: Sun Jul 30, 2006 5:56 pm

Re: Create scheduled task to run a macro or program

Postby ldarrambide on Fri Apr 05, 2013 4:57 pm

Thanks, need to change my shades...
ldarrambide
Active Member
 
Posts: 770
Joined: Wed Feb 25, 2009 1:10 am

Re: Create scheduled task to run a macro or program

Postby Kevin on Fri Apr 05, 2013 5:00 pm

:lol: np can happen to anyone
Kevin
Active Member
 
Posts: 359
Joined: Sun Jul 30, 2006 5:56 pm

Re: Create scheduled task to run a macro or program

Postby pedrotairum on Thu Apr 11, 2013 2:59 pm

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
pedrotairum
 
Posts: 97
Joined: Tue Jan 15, 2013 3:32 pm

Re: Create scheduled task to run a macro or program

Postby Gintaras on Thu Apr 11, 2013 3:20 pm

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

Gintaras
Site Admin
 
Posts: 10299
Joined: Thu Dec 19, 2002 7:36 pm
Location: Lithuania

Re: Create scheduled task to run a macro or program

Postby ssimop on Tue Jul 18, 2017 8:13 pm

I wonder whether there exists a member function to schedule at odd or even days of the year. Many thanks for any advice.
User avatar
ssimop
Active Member
 
Posts: 893
Joined: Sun Oct 21, 2007 1:55 pm
Location: Greece

Re: Create scheduled task to run a macro or program

Postby Gintaras on Tue Jul 18, 2017 8:36 pm

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

Gintaras
Site Admin
 
Posts: 10299
Joined: Thu Dec 19, 2002 7:36 pm
Location: Lithuania

Re: Create scheduled task to run a macro or program

Postby ssimop on Tue Jul 18, 2017 11:39 pm

Many thanks indeed!
User avatar
ssimop
Active Member
 
Posts: 893
Joined: Sun Oct 21, 2007 1:55 pm
Location: Greece


Return to QM Extensions

Who is online

Users browsing this forum: No registered users and 1 guest

cron