#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
Opt("MustDeclareVars", 1)
Global Const $gc_FormName = "随机数字"
#Region
Global $gu_Form1 = GUICreate($gc_FormName, 304, 105, -1, -1)
Global $gu_Group1 = _
GUICtrlCreateGroup("29选7随机选号", 8, 8, 289, 57)
Global $gu_Input1 = GUICtrlCreateInput("", 16, 32, 33, 21, _
BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER))
Global $gu_Input2 = GUICtrlCreateInput("", 56, 32, 33, 21, _
BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER))
Global $gu_Input3 = GUICtrlCreateInput("", 96, 32, 33, 21, _
BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER))
Global $gu_Input4 = GUICtrlCreateInput("", 136, 32, 33, 21, _
BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER))
Global $gu_Input5 = GUICtrlCreateInput("", 176, 32, 33, 21, _
BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER))
Global $gu_Input6 = GUICtrlCreateInput("", 216, 32, 33, 21, _
BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER))
Global $gu_Input7 = GUICtrlCreateInput("", 256, 32, 33, 21, _
BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER))
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $gu_Button1 = GUICtrlCreateButton("关于", 8, 72, 49, 25)
Global $gu_Button2 = GUICtrlCreateButton("选号", 192, 72, 49, 25)
Global $gu_Button3 = GUICtrlCreateButton("复制", 248, 72, 49, 25)
#EndRegion
Global $gua_Input[8] = ["", $gu_Input1, $gu_Input2, $gu_Input3, _
$gu_Input4, $gu_Input5, $gu_Input6, $gu_Input7]
_Main()
Exit
Func _Main()
GUISetState(@SW_SHOW)
Local $nMsg
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $gu_Button1
MsgBox(0 + 64, $gc_FormName, _
"本程序用于29选7随机选号")
Case $gu_Button2
Local $a_Numbers = _RandomNumber()
_SortArray($a_Numbers)
_DisplayNumbers($a_Numbers)
Case $gu_Button3
_CopyNumbersToClip()
EndSwitch
WEnd
EndFunc ;==>_Main
Func _RandomNumber()
Local $a_Numbers[1], $p = 1
While $p <= 7
Local $Number = Random(1, 29, 1)
Local $i, $f = 1
For $i = 1 To UBound($a_Numbers, 1) - 1
If $a_Numbers[$i] = $Number Then
$f = 0
ExitLoop
EndIf
Next
If $f = 1 Then
ReDim $a_Numbers[$p + 1]
$a_Numbers[$p] = $Number
$p += 1
EndIf
WEnd
;;_ArrayDisplay($a_Numbers,"$a_Numbers")
Return $a_Numbers
EndFunc ;==>_RandomNumber
Func _SortArray(ByRef $a_Array)
Local $i
For $i = 1 To UBound($a_Array, 1) - 2
Local $j
For $j = $i + 1 To UBound($a_Array, 1) - 1
If $a_Array[$i] > $a_Array[$j] Then
_ExchangeNumber($a_Array[$i], $a_Array[$j])
EndIf
Next
Next
;;_ArrayDisplay($a_Array,"$a_Numbers")
EndFunc ;==>_SortArray
Func _ExchangeNumber(ByRef $Num1, ByRef $Num2)
Local $t
$t = $Num1
$Num1 = $Num2
$Num2 = $t
EndFunc ;==>_ExchangeNumber
Func _DisplayNumbers($a_Numbers)
Local $i
For $i = 1 To 7
GUICtrlSetData($gua_Input[$i], $a_Numbers[$i])
Next
EndFunc ;==>_DisplayNumbers
Func _CopyNumbersToClip()
Local $s = ""
Local $i
For $i = 1 To UBound($gua_Input, 1) - 1
$s &= GUICtrlRead($gua_Input[$i]) & ", "
Next
$s = StringTrimRight($s, 2)
ClipPut($s)
EndFunc ;==>_CopyNumbersToClip
研究一下这个吧!Skyfree写的!