Random action from a group?

Is there any way one of the actions in the group executed randomly?

When macro executed, I want one of the actions in the group randomly chosen and executed.

How about this? Bear in mind that, because it really is random, you will get repeat results; i.e. the same action may be executed multiple times in succession. The smaller the number of actions to choose from, the higher the likelihood of this happening.

Random Click.kmmacros (24 KB)

Macro screenshot

I tried to come up with a way to avoid repeats. The idea is that the random number generation would repeat until it isn't the same as the previous number. For testing purposes, I've disabled your click actions and instead the macro displays the current and previous numbers onscreen. As you will see, the numbers are occasionally the same, so my method clearly doesn't work. Maybe someone else will know why.

Random Click (No Repeats).kmmacros (25 KB)

Macro screenshot

I'm sure you know why already. This bit needs to be like this:

Otherwise it is looking for matching "1" "2" "3" etc to the text "LastRandom" rather than to what the Variable LastRandom is holding.

Well that's embarrassing. Of all the simple mistakes... :man_facepalming:t2:

Here you go!

Random Click (No Repeats).kmmacros (25 KB)

Macro screenshot

1 Like