Bueno después de este cuento vamos al tema, un sencillo programita para calcular al azar un número ganador sacado de un número de participantes. El code es tal cual salió en el evento así que no está muy cuidado, pero es funcional.
Aquí una captura de pantalla: Y el code:
Código: Seleccionar todo
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1_1 = GUICreate("Sorteo", 373, 281, 334, 221)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1_1Close")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "Form1_1Minimize")
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "Form1_1Maximize")
GUISetOnEvent($GUI_EVENT_RESTORE, "Form1_1Restore")
$participantes = GUICtrlCreateInput("", 40, 64, 81, 21)
GUICtrlSetOnEvent(-1, "participantesChange")
$Sortear = GUICtrlCreateButton("Sortear", 192, 24, 139, 73)
GUICtrlSetOnEvent(-1, "SortearClick")
$Label1 = GUICtrlCreateLabel("Participantes", 40, 40, 65, 17)
GUICtrlSetOnEvent(-1, "Label1Click")
$Input1 = GUICtrlCreateInput("", 40, 120, 289, 84)
GUICtrlSetFont(-1, 50, 800, 2, "Arial")
GUICtrlSetColor(-1, 0xFF0000)
GUICtrlSetOnEvent(-1, "Input1Change")
$Label2 = GUICtrlCreateLabel("Ganador", 40, 104, 45, 17)
GUICtrlSetOnEvent(-1, "Label2Click")
$Label3 = GUICtrlCreateLabel("", 16, 232, 336, 23)
GUICtrlSetFont(-1, 12, 800, 0, "Arial")
GUICtrlSetColor(-1, 0xFF0000)
GUICtrlSetOnEvent(-1, "Label3Click")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $sortear
sorteo()
EndSwitch
WEnd
Func sorteo()
$LowerLimit = 1
$UpperLimit = GUICtrlRead($participantes, 1)
For $i = 0 To 10 Step +1
$RandomNumber = Random($LowerLimit,$UpperLimit,1)
GUICtrlSetData($Input1, $RandomNumber)
Sleep(400)
Next
$RandomNumber = Random($LowerLimit,$UpperLimit,1)
GUICtrlSetData($Input1, $RandomNumber)
GUICtrlSetData($Label3, "El ganador es el participante nº." & $RandomNumber )
EndFunc
Un saludo amigos.