#Persistent
InputBox, MAX, Lotto, Please enter the MAXIMUM numbers in the lottery., , ,
InputBox, N, Lotto, Please tell me how many numbers to generate.`nThis will work for up to 11 numbers.`nSelection will be Between 1 and %MAX%, , ,
;N := 7
MIN := 1
;MAX := 45
If (MAX - MIN + 1 < N)
{
MsgBox Cannot have %N% different numbers between %MIN% and %MAX%
return
}
generate_numbers:
Loop %N%
{
i := A_Index
loop
{
Random R, %MIN%, %MAX% ; R = random number
j := Index_%R% ; get value from Indexes
If j is number
If j between 1 and % i - 1
If (R_%j% = R)
continue ; repetition found, try again
Index_%R% := i ; store index
R_%i% := R ; store in R_1, R_2...
break ; different number
}
}
MsgBox,5,Below are your random numbers,Below are your %N% Numbers`n`n%R_1%`n%R_2%`n%R_3%`n%R_4%`n%R_5%`n%R_6%`n%R_7%`n%R_8%`n%R_9%`n%R_10%`n%R_11%`n`nUse CTRL+C to copy
IfMsgBox Cancel
Exitapp
else
goto generate_numbers
Return