Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Create scheduled task to run a macro or program
#1
Macro ScheduledTask help
Code:
Select All      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.


Attached Files
.qml   ScheduledTask.qml (Size: 11.23 KB / Downloads: 760)
#2
Quote:install QM 2.3.5.3

Any link? Only 2.3.5.2 in forum from my searches...
#3
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.
#4
Thanks, need to change my shades...
#5
:lol: np can happen to anyone
#6
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:

Code:
Select All      Help
#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! Big Grin
#7
From SetAdvancedScheduleOptions help:
Sets options for the last added schedule...

Macro Macro1991
Code:
Select All      Help
#compile "__ScheduledTask"
ScheduledTask T

T.Create("teste")
T.ScheduleOnceAfter("0:1")
T.SetAdvancedScheduleOptions("" "" 1 100)
T.Save
#8
I wonder whether there exists a member function to schedule at odd or even days of the year. Many thanks for any advice.
#9
Try this. Not tested.

Macro Macro2865
Code:
Select All      Help
#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
Code:
Select All      Help
DateTime d.FromComputerTime
if d.GetDayOfYear&1
,out 1
else
,out 2
#10
Many thanks indeed!


Forum Jump:


Users browsing this thread: 1 Guest(s)