Random Text from a list of 10 or so choices

@gglick

I would like to ask both of you,
instead of choosing text randomly, can we make macro to choose text one after the other.

I mean, first time I run macro, it should choose first line of text from the list. Second time I run macro, it should choose second line of text from the list. and so on

I also have asked same question here

There are lots and lots of ways to do this in Keyboard Maestro. But the key is understanding that after each Macro run one thing that can persist (and provide a count of how many times you have run the Macro) is a Global Variable.

So, you make a Global Variable of "1" and the first time the Macro is run it adds "1" to that, making the Variable "2". And the next time you run the Macro is adds another "1" making the Variable "3" etc. This is the way the Macro knows how many times it has run and can choose which bit of text to display/use. Once you reach the total of however many pieces of text you have the Variable is reset to "1" and the cycle can start again.

Here is an example, to show the concept.

(It is just an example as I do not know what form your original "lines" of data are. Whatever they are, there will be a way for Keyboard Maestro to get at each line and cycle them on each Macro run.)

EXAMPLE Cycle through list on each Macro run.kmmacros (11.0 KB)

Click to Show Image of Macro

2 Likes

Thank you so much.
Let me try this out.

Hey I tried but 'Set variable __ to calculation __' is giving me error. See the text color changed from white to orange in the screenshot

Here is a screenshot of error msg as well:
Screen Shot 2022-10-25 at 16.27.05

The orange colour is because at this point in writing the Macro, ytintro_counter doesn't exist. But on first run the Macro should create ytintro_counter.

I have tried it on my Mac and it works.

(The top of your screenshot is not showing all the conditions for the If Then. It should be set so that "any" of the following are true, not "all".)

1 Like

Thanks for the prompt reply. That really saves from getting discouraged.

Thanks for letting me know. While I was exploring, I went ahead into setting and put the value as '1' for ytintrol_counter, which was earlier showing as 'default value'.
And that worked.

And all the credit goes to you. Thank you.

1 Like