RAND, RANDOM(10,20) Keeps Changing in the Keyboard Maestro Editor


I want to run a macro for 10~20 min ( randomly ).

I added RAND(10,20) and also tested RANDOM.
But it keeps changing.

11, 14, 17, 18

Did I miss anything?

Thank you,

You're looking at that in the Keyboard Maestro Editor – right?

Not during execution.

In many actions, when displayed in the editor, Keyboard Maestro will show at the bottom of the action the current value of the calculation/token expansion (and before the arrow will show the current value of the destination of the action). For example:

image

The value of the variable Day is currently “Saturday” and the value of the token expansion of “%ICUDateTime%EEEE%” is currently “Monday”.

The editor re-evaluates the token/calculation every second.

So you are simply seeing the value of the calculation “RANDOM(10,20)” evaluated every second.

Hey, ccstone. Sorry, I don't understand what you mean. Do you mean "Pause Random dosn't work during any execution?"

I just want to get any random number ( 10~20 min ) when it's repeat.


For now, I added "9" min . But this should be random min. ( 10~20 )

Oh, so RAND function is for every second? I didn't know that. I don't know that how we can use this function.

Is there any way to get a random number ( 10~20) whenever repeat runs?


I added "9" for temp min. But it should be 10~20 min randomly.

Thank you,

No, RAND gives a random different (well, probably different) result every time it is evaluated.

The editor just happens to evaluate it for display every second.

Yes, just use RAND(10,20) in that field.

It will be evaluated once each time the action runs, and then pause for that number of minutes.

If you use RAND(10,20) it will always pause for a multiple of minutes, 10 to 20 (so it might be exactly 13 minutes for example). If you use RANDOM(10,20) it will pause for a random amount of time between 10 minutes and 20 minutes (so it might be13 minutes and 23.78 seconds).

Each time the Pause action is executed the calculation will be evaluated, so each time through the loop it will pause a different amount of time.

2 Likes