Running an action only when certain criteria met

I'm creating a hotkey-triggered macro that, before anything else, does a "prompt for user input" action. Is it possible to tell KM to run just this action only under certain conditions? Ideally, the action would run the first time I trigger the macro daily (or maybe something like when I trigger the macro and the user prompt action hasn't been run in the last 12 hours.) To be clear, the rest of the macro's actions should be executed without meeting these or any other conditions outside the initial trigger.

If I understand you correctly (and I'm only 90% sure that I do) you have asked for two possible implementations, and I will pick the second one, which I think is slightly easier...

The first IF statement is saying "if you don't have a global variable indicating the last time that the Prompt action was run, create the variable and set it's value to yesterday ("-1"). "

MJD() returns the current day as a number (with a fraction representing partial days) and MJD()-1 would therefore mean "exactly yesterday at this time."

The second IF statement is saying "if it has been over a half day (0.5) since it was last run, then execute the Prompt command and record the time into the global variable."

Now there's a chance I have misunderstood you. So if you let me know, I can fix this code.

The reminder of your macro will follow these two actions, and will always be executed regardless of whether the Prompt action is executed. I think that's what you were asking for.

1 Like

This worked, thank you so much!

Thanks. There are other ways to solve the same problem. But that's one of the simpler methods.

1 Like