Does a way to randomly choose a macro exist?

Exactly what the title says. Is there a macro to give a random output or execute a random macro from a group?

Hey There,

Create a list of Macro UUIDs or names.

Use the random(int) function and seed it with the number of macros.

Take the result and get the corresponding line in your list.

A basic example in AppleScript:

# Represents a list of macro names or UUIDs.
set myMacroList to paragraphs of "one
two
three
four
five
six
seven
eight
nine
ten"

tell application "Keyboard Maestro Engine"
   set randomNum to process tokens "%Calculate%RAND(10)%"
   set myMacro to item (randomNum + 1) of myMacroList
   do script myMacro
end tell

-Chris

1 Like

Use the Switch action, with the text option, and %Calculate%RAND(10)% token, and then 10 case entries with 0, 1, 2, … 9.

Although why on earth this makes sense I have no idea.