Prompt for User Input —> Run a Macro at a Later Time?

I want to prompt the user to specify a time in the future (either a specific time/date or "+4 hours from now") and have that time be used to run a macro at that time.

There has to be a way to do this, but my brain is not firing on all cylinders or something, because I'm not getting it.

Hey @tjluoma, I would attend to this more fully had I a working computer, which I don’t right now. But I posted something recently that demonstrates one technique that would probably be extremely effective for this particular task.

I’ll just post the link to my first post in some other thread, and you can see what you are able to pull from that to adapt to this use case.

If you hit a roadblock, holla back with whatever you got, and either I’ll have my computer fixed or will just clarify whatever isn’t gleaned from above.

1 Like

How precisely do you want to be able to trigger it?

Because the easiest way would be for a macro to simply set a specific time into a variable, and have another macro run periodically and check if that time has passed. And how precisely you want to specify the time determines the trigger period.

Although, you could do this:

Macro 1:

  • Ask for the time
  • Figure out the time
  • Set variable When to a time to trigger (based on NOW function).
  • if NOW() < When - 3600
    • Enable Macro 2 “Check Hourly”
  • else
    • Enable Macro 3 “Check Every Minute”

Macro 2 “Check Hourly” (initially disabled)
Triggered every hour

  • if When > NOW() - 3600
    • Disable Macro 2
    • Enable Macro 3

Macro 3 “Check Every Minute” (initially disabled)
Triggered every minute

  • if When > NOW()
    • Disable Macro 3
    • Do Stuff

That way it only checks every hour until the time approaches, and then every minute.

The alternative would be to use an AppleScript to create a macro with a specific trigger, but that starts to get messy. Doable, and probably no more complex than the above, but messy.

Wow. Very clever. No wonder I didn't just come up with that on my own. I'll see if I can put something together.

Thanks for the suggestion.

You could also hack the XML of a macro with a Cron trigger.

A bit more work to initially setup, but then you don't need a frequent periodic trigger running (every minute?) to check. Chris @ccstone and I have posted some examples of hacking a macro's XML. If you need help, let us know.

1 Like

Yup. That's what I would do, and hopefully @tjluoma finds the link I posted helpful. I didn't find implementing it messy at all, and, if anything, much less complex than @peternlewis's method (though his is likely to be more adaptable to more situations, and has the benefit of being able to recognise when a scheduled trigger has not been able to run the macro at the exact time and do it as soon as it is able).

1 Like