Looping after collecting info? Moving on past loop?

For me, the following macro structure comes up a lot:

. Get info (can be URLs, mouse location, controls locations, count of items, text, etc.), usually to variables
. Repeat a group of Actions if I want to.

One way I do this is to have two macros, one to get the info, another to do the job.

This requires triggering separate macros with different triggers, which I would like to avoid.

Another way I've done this is using a "Prompt for User Input" Action within a "Repeat" Action which allows me to cancel the macro rather than continue to repeat the sub-group.

But many times I would like the macro to continue after stopping the "Repeat" loop.

Something similar (to me) comes often: I need repeat a group of actions a known number of times, but either the first repeat or the last one is different, often by only one Action.

I can of course simply copy and paste Actions and make a single "straight-line" macro. The problem that creates is that when I emend the macro I usually have to change two or more instances of the same Action.

What is the best way to handle looping and branching?

I'm not sure I understand your problem, but I don't see a need to have separate Macros.
Maybe if you post one of your real-world macros as a example, it would be more clear.

I do this all the time, all in ONE Macro:

  • Use a few Actions (maybe only one) to get the data to process
  • Use one of the KM Looping Actions to process
  • If the processing needs to vary based on the data then you can use:
    • If Then Else action if you have only two choices
    • Switch/Case Action if you have multiple cases based on the data
    • My favorite is Switch/Case, which I often use.

I'll stop here until I better understand your question.
Again, please post a real Macro that illustrates the common design pattern you use.

LOL (@me). I have never looked at the Switch/Case Action, having assumed it switched (letter) case, which I have always done other ways. It is — as you indicate — the great tool for my tasks.

Off to work I go, whistling and smiling. I have a whole bunch of ganged macros (ganged by me — I number them in an attempt to keep the flow clear to me without reading through each macro, e.g.: DoThis 1.0; DoThis 1.1; DoThis 1.2.0; DoThis 1.2.1; DoThis 1.2.2; DoThis 1.3, DoThis 2.0; etc. I will look into the looping Actions as well, and post back with specifics.

Thank you :blush: .

1 Like

@Kirby_Krieger, I'm glad to help. If it helped you, then it is likely that it will also help others.
So this is probably a good thread for those new to KM.