Randomly Select Task Macro (v10.2)

The attached macro presses the down arrow x number of times, where x is whatever number I input.

But I need the macro to work slightly differently. I need to input a number, then the macro needs to choose a random whole number between 1 and whatever number I input. Then the macro needs to press the down arrow x number of times, where x is whatever random number has been selected.

For example, let's say I input the number 150 and the random number chosen between 1 and 150 happens to be 73, I need the macro to press the down button 73 times.

In another iteration, let's say I input the number 20 and the random number chosen between 1 and 20 happens to be 14, I need the macro to press the down button 14 times.

Is this possible?a

Randomly select task Macro (v10.2)

Randomly select task.kmmacros (3.1 KB)

https://wiki.keyboardmaestro.com/function/RANDOM

The RANDOM() functions return a random real number.

  • RANDOM(A,B) returns (v9.0+) a random real number from A to, but not including, B.

Your requirement can be implemented with KM.

To generate whole numbers (integers) it’s best to use the RAND function. For example

  • RAND(A,B) returns (v9.0+) a random integer number from A to, including, B.

See the KM wiki function:RAND [Keyboard Maestro Wiki]

Thanks for pointing out the difference between RAND and RANDOM.

1 Like