# Lottery Number Picker

## Recommended Posts

I'm a beginner, so be kind...

```#include <Array.au3>
#include <GUIConstants.au3>

Opt("GUIResizeMode", 1)
Opt("GUIOnEventMode", 1)

Dim \$avArray[6]
\$avArray[0] = Random(1, 49, 1)
Do
\$avArray[1] = Random(1, 49, 1)
Until \$avArray[1] <> \$avArray[0]
Do
\$avArray[2] = Random(1, 49, 1)
Until \$avArray[2] <> \$avArray[0] AND \$avArray[2] <> \$avArray[1]
Do
\$avArray[3] = Random(1, 49, 1)
Until \$avArray[3] <> \$avArray[0] AND \$avArray[3] <> \$avArray[1] AND \$avArray[3] <> \$avArray[2]
Do
\$avArray[4] = Random(1, 49, 1)
Until \$avArray[4] <> \$avArray[0] AND \$avArray[4] <> \$avArray[1] AND \$avArray[4] <> \$avArray[2] AND \$avArray[4] <> \$avArray[3]
Do
\$avArray[5] = Random(1, 49, 1)
Until \$avArray[5] <> \$avArray[0] AND \$avArray[5] <> \$avArray[1] AND \$avArray[5] <> \$avArray[2] AND \$avArray[5] <> \$avArray[3] AND \$avArray[5] <> \$avArray[4]

_ArraySort(\$avArray)

GUICreate("Lottery Picker", 670, 120)
GUISetFont(12, -1, 4, "Tahoma")
GUISetOnEvent(-3, "ClosePressed")
GUICtrlCreatePic(GetBall(\$avArray[0]), 10, 10, 100, 100)
GUICtrlCreateLabel (\$avArray[0], 50, 50, 20, 20, \$SS_CENTER)
GUICtrlSetBkColor(-1, GetColour(\$avArray[0]))
GUICtrlCreatePic(GetBall(\$avArray[1]), 120, 10, 100, 100)
GUICtrlCreateLabel (\$avArray[1], 160, 50, 20, 20, \$SS_CENTER)
GUICtrlSetBkColor(-1, GetColour(\$avArray[1]))
GUICtrlCreatePic(GetBall(\$avArray[2]), 230, 10, 100, 100)
GUICtrlCreateLabel (\$avArray[2], 270, 50, 20, 20, \$SS_CENTER)
GUICtrlSetBkColor(-1, GetColour(\$avArray[2]))
GUICtrlCreatePic(GetBall(\$avArray[3]), 340, 10, 100, 100)
GUICtrlCreateLabel (\$avArray[3], 380, 50, 20, 20, \$SS_CENTER)
GUICtrlSetBkColor(-1, GetColour(\$avArray[3]))
GUICtrlCreatePic(GetBall(\$avArray[4]), 450, 10, 100, 100)
GUICtrlCreateLabel (\$avArray[4], 490, 50, 20, 20, \$SS_CENTER)
GUICtrlSetBkColor(-1, GetColour(\$avArray[4]))
GUICtrlCreatePic(GetBall(\$avArray[5]), 560, 10, 100, 100)
GUICtrlCreateLabel (\$avArray[5], 600, 50, 20, 20, \$SS_CENTER)
GUICtrlSetBkColor(-1, GetColour(\$avArray[5]))

GUISetState(@SW_SHOW)

; Just idle around
While 1
Sleep(10)
Wend

Func GetColour(\$value)
Select
Case \$value < 10
\$colour = "0xFFFFFF"
Case \$value < 20
\$colour = "0xAEC8EB"
Case \$value < 30
\$colour = "0xFD9DAA"
Case \$value < 40
\$colour = "0x5CA03C"
Case \$value < 50
\$colour = "0xF2E142"
EndSelect
Return \$colour
EndFunc

Func GetBall(\$value)
Select
Case \$value < 10
\$ball = "white.bmp"
Case \$value < 20
\$ball = "blue.bmp"
Case \$value < 30
\$ball = "pink.bmp"
Case \$value < 40
\$ball = "green.bmp"
Case \$value < 50
\$ball = "yellow.bmp"
EndSelect
Return \$ball
EndFunc

Func ClosePressed()
Exit
EndFunc```

Produces:

Code and images attached (zipped).

Lottery_Picker.zip

Edited by Valiante

## Create an account

Register a new account

×

• Wiki

• Back

• Git