Looking to have a macro start a month from now, using a date trigger. Possible? Thanks!
I think the only way to do that is to use the Calendar app to run an AppleScript to tell a Keyboard Maestro macro to run.
It was an interesting question to me, so I just tried it. It works, but you have to make sure that you save the script as an executable… and also, you should run it manually at least once before you try to trigger it by the calendar, because the first time you run it it asks you to confirm you really want to run it.
Calendar triggered AppleScripts are appropriate when you want to run a macro based on a calendar entry, especially if this is a one off action.
And the AppleScript in turn can easily trigger a macro if the action is something Keyboard Maestro can help you with.
For repeating actions, you can trigger a macro at a specific time on specific days of the week.
And if you want a macro to run on specific days of the month or even once a year or whatever, you can trigger the macro every day and then have the macro test the DAY() and/or MONTH() function values to determine whether today is the day to run.
@peternlewis I don’t know how difficult it would be to implement or whether or not this would be a good feature for Keyboard Maestro to have but I would certainly find useful the ability to trigger one-off events some way other than either the Calendar app—which is tedious at best—or the UNIX
at command—which runs in the background and doesn’t carry over after rebooting.
One possibility is
launchd, which is useful for many things but doesn’t run a job if the system is powered off during the time the job was scheduled. If Keyboard Maestro could ensure that a job were run at or after a single specific point in time, I’d find that very useful!
I guess the question would be how to deal with it afterwards. Delete the trigger once it’s happened? But that doesn’t work well since the engine can’t modify the macros (and what happens with syncing then too, that’s a mess).
I certainly could have a date trigger that triggered on a specific year/month/day/hour/minute/second, but then I’d have to track whether it had fired or not to know whether to trigger it on launch, so that’s pretty ugly.
You can do it yourself though, something like this:
Trigger periodically (however you like, hourly perhaps)
Trigger every day at the desired time (for good measure)
If calculation YEAR()*10000000000+MONTH()*100000000+DAY()*1000000+HOUR()*10000+MINUTE()*100+SECOND() > 20150430083000 then
Disable This Macro
And that’s where the gold lies!
With your snippet, I can imagine a two tier system:
- A starter macro that runs once daily, exists solely to enable other worker macros, and ensures they were run the following day via a boolean variable check
- Worker macros that once enabled, run at some point during the day and, upon successful completion, disable themselves and send back their exit status for the starter macro
Not perfect but a start!
I’m new to using the date function in KM. I’m trying to develop a macro that will trigger another macro at a specific day of the month, hour of that day and minute, but the devil is in the detail. I can’t tell from your response exactly how to use the DAY, HOUR and MINUTE functions.
I set up an enabling macro to trigger a few minutes from current time every day of the week to execute the following actions:
If All Conditions Met Execute Actions
If all the following are true:
(using, as a test, current values for DAY and HOUR and a future value for MINUTE later than the trigger time entered between the parentheses)
…and selected a macro to execute at that time
However, when the future value of MINUTE was reached the desired action did not occur and “(currently false)” remained displayed. How does the enabling marcro need to be modified?
The calculation condition is true if and only if the calculation result is not zero.
So the calculation DAY() will always be true, since the DAY function always returns a number from 1 to 31, never 0.
Post your complete macro (or a copy of it with the the actions within the IF removed and replaced with a trivial action like Notify “Doit”). Then we can point out exactly where you are going wrong.
Thanks. I later discovered by reading a different post that I was going about what I wanted to do the wrong way to schedule a macro to run at a certain time on a future day of the month more than a week away. I should have been using DAY() = X (where X is the number 1-31 of the future day of the month) in order to make a marcro run on a certain day using the IF…THEN action in conjuction with the time-of-day + day-of-the-week trigger. I’m using the macro to set a monthly schedule of QuickTime recordings from a video source at various days and times of the month (not usually the same day of the week) and simply make a number of copies of the macro, with each copy set to run at one of the various days and times by changing the trigger time and the value for X, above, all days of the week being selected. I’m wondering, though, if there can be a trigger on time-of-day + day-of-the-week, why couldn’t time-of-day + day-of-the-month be made a trigger? Nevertheless, now I have a macro that does what I want, when I want.
The Time trigger could be extended to specify the day of the month, and/or month of the year. It is not currently done, but it is on the todo list.
Keyboard Maestro is not necessarily good at this sort of thing though because it does not operate when the Mac is asleep, so if a time is missed it will be lost.