I am running a script in the macro scheduler... and need a daily time check

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
diamondrail
Junior Coder
Posts: 20
Joined: Wed Jul 31, 2019 9:38 am

I am running a script in the macro scheduler... and need a daily time check

Post by diamondrail » Fri Aug 16, 2019 12:13 am

If I am running a script, and once a day I need it to run another set of code within the script. How can I implement this? See attachment for the logic.

Thank you.

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1348
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: I am running a script in the macro scheduler... and need a daily time check

Post by Dorian (MJT support) » Fri Aug 16, 2019 12:44 pm

Hi Diamondrail,

There's lots of ways of doing this. This is just one of them. It works with 0935 or 935. Whichever you choose.

For anyone wanting to use this method after 12pm, it uses the 24hr clock, so simply use 1335, 1435, and so on.

I included a small wait to avoid a tight loop :

Code: Select all

Label>Start
Hour>TheHour
Min>TheMins

If>%TheHour%%TheMins%=935
  MessageModal>Action script goes here
Else
  Wait>1
  Goto>Start
Endif

Yes, we have a Custom Scripting Service. Message me or go here

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1348
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: I am running a script in the macro scheduler... and need a daily time check

Post by Dorian (MJT support) » Fri Aug 16, 2019 12:45 pm

How many other ways can our regular users think of to achieve this?
Yes, we have a Custom Scripting Service. Message me or go here

User avatar
Grovkillen
Automation Wizard
Posts: 1009
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Re: I am running a script in the macro scheduler... and need a daily time check

Post by Grovkillen » Sat Aug 17, 2019 11:38 am

I do it like this:

Code: Select all

//Check loop
Label>StartOfLoop
Hour>HH
Min>MM
Sec>SS
GoSub>CheckClock,%HH%:%MM%:%SS%
Wait>0.25
Goto>StartOfLoop

SRT>CheckClock
If>CheckClock_Var_1=12:00:00
//Send to sub
Endif>

//Add more checks

END>CheckClock
Let>ME=%Script%

Running: 15.0.24
version history

User avatar
JRL
Automation Wizard
Posts: 3497
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: I am running a script in the macro scheduler... and need a daily time check

Post by JRL » Mon Aug 19, 2019 5:09 pm

One more

Code: Select all

OnEvent>Time,0935,,RunDifferentLineOfCode

Label>RunLinesOfIrrelevantCode
  Wait>1
Goto>RunLinesOfIrrelevantCode

SRT>RunDifferentLineOfCode
  MDL>Its 9:35 am.%crlf%Now we wait a minute else we'd just keep running this Sub over and over until 9:36 am
  Wait>61
END>RunDifferentLineOfCode

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1348
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: I am running a script in the macro scheduler... and need a daily time check

Post by Dorian (MJT support) » Tue Aug 20, 2019 10:32 am

Thank you for those.

It's always so nice to see how other people do things.

No matter how long we've been doing this we never seem to stop learning.
Yes, we have a Custom Scripting Service. Message me or go here

User avatar
Grovkillen
Automation Wizard
Posts: 1009
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Re: I am running a script in the macro scheduler... and need a daily time check

Post by Grovkillen » Tue Aug 20, 2019 5:37 pm

What I like about my approach is that you can add as many checks as you want and also send day (number) of the week, month or whatever to have long time tasks triggered in the same mechanism.
Let>ME=%Script%

Running: 15.0.24
version history

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts