![]() |
KnowBrainer Speech Recognition | ![]() |
Topic Title: Help with a random 50/50 "coin flip" command? Topic Summary: How to make a KB Command to randomly choose between 0 or 1, then type out the result? Created On: 03/02/2022 08:42 PM Status: Post and Reply |
|
![]() |
|
How would I make a KB Command to randomly choose between 0 or 1 (two results), then type out the result?
Really need something like this for some work I'm doing, and I'd need this for dozens of values in an Excel sheet. |
|
|
|
![]() |
|
A very quick Advanced Scripting approach might be:
'#Language "WWB-COM" Option Explicit Sub Main Dim ThisSecond As String ThisSecond = Format(Now, "s") / 60 If ThisSecond > 0.5 Then SendKeys "1" Else SendKeys "0" End If End Sub -------------------------
|
|
|
|
![]() |
|
I prefer the one-liner:
MsgBox "Random Number " & CStr(Int((2 * Rnd) + 1))
(The "2" can be changed to other dice numbers). Hth, -------------------------
|
|
|
|
![]() |
|
A lot more elegant of course, PG. I wasn't aware of the Rnd instruction being availaible here.
-------------------------
|
|
|
|
![]() |
|
I wasn't aware of it either. Here's information about that function: |
|
|
|
![]() |
|
PG LTU, the "MsgBox "Random Number " & CStr(Int((2 * Rnd) + 1))" was the closest one to what I was looking for, though it's not amazing for doing many, many numbers in a row quickly.
Not exactly what I was looking for, but thanks for everyone's help & time regardless. ![]() |
|
|
|
![]() |
|
Uhm, unclear what you _are_ looking for. The responses are meant as exemplary. You could easily change a MsgBox to SendKeys if that's the problem (RW obviously read the question closer than I did). Did you want multiple numbers in a row? Perhaps this model can get you started. I call the command "some random numbers"
'#Language "WWB-COM"
and the output is as such (in under a second): Some Random Numbers 1 2 2 1 2 2 1 2 2 1 2 1 2 2 2 1 2 1 1 2 1 2 1 1 1 2 2 2 2 2 1 1 1 1 2 2 1 1 2 1 1 1 2 2 2 1 1 1 2 1
Hth, -------------------------
|
|
|
|
![]() |
|
In a blink of an eye, here are 1000 (just by changing 50 to 1000):
Some Random Numbers 1 1 2 2 2 1 2 2 2 2 1 1 1 2 1 2 1 2 1 1 2 1 2 1 1 2 1 1 2 2 1 1 2 2 2 2 2 2 2 1 1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