Rewind an Action, or Go Back?

I'm designing a sort of "Tutorial" in Keyboard Maestro so that my macros can be easily used by other people on my team. I'm anticipating that sometimes my colleagues will want to go back in the tutorial in case they missed something. Is there a way in KM where in a Prompt, I can have an option that is called "Go Back", and it'll open up the previous prompt/action?

Hey John,

There's no convenient way to do that, however it seems to me it might be done with some creative use of flow-control.

-Chris

If you use a master macro that calls other macros using the Execute a Macro action, then you could offer a picklist in the Prompt to choose the tutorial step to go back to.

Questions?

Yes, I guess that would work. Although I was hoping there'd be another way that wouldn't require me to divy up the whole macro into separate macros. I already have my tutorial divided up into separate macros, so I'd have to pull them apart little more granularly.

One solution I found was just having a "Restart Tutorial" button at the end, which then re-runs the tutorial if that button is pressed. That should probably be sufficient.

Thanks for the help!

Keyboard Maestro does not have a “goto”, but what you can do is structure the whole thing as a state machine. This is relatively easy to do using a Switch action.

The basic structure would look like this:

  • Set variable State to "Start" (or you can use numbers if you prefer)
  • While State is not “Done” do
    • Switch on variable State
      • Case is “Start”
        • Prompt for User Input
        • Do whatever
        • Set variable State to "Step1"
      • Case is “Step1”
        • Prompt for User Input
        • Do whatever
        • Set variable State to "Step2"
      • Case is “Step2”
        • Prompt for User Input
        • Do whatever
        • If whatever condition
          • Set variable State to "Step1"
        • Else
          • Set variable State to "Step3"
      • Case is “Step3”
        • Prompt for User Input
        • Do whatever
        • Set variable State to "Finished"

This sort of structure will let you do any sequence, and step to any position as required.

1 Like

Hmm, that's a really interesting solution. If you set the Switch to a sequence of numbers, then when you can set the variable to a calculation and simply add 1 for each step.

Thanks, I might use that!