join Posted October 11, 2008 Share Posted October 11, 2008 (edited) in this guide i will explain how to generate random numbers OBS i did NOT make all this my self, sadly i forgot who made this script (well, the creators of autoit i guess xD) 1. if you just want a pop-up box use the code below, u can change it if you want, but only if you know what you do (very easy, but still) $one = 1 $ten = 3000 $RandomPick1 = Random($one,$ten,1) $RandomPick2 = Random($one,$ten,1) $RandomPick3 = Random($one,$ten,1) $RandomPick4 = Random($one,$ten,1) $RandomPick5 = Random($one,$ten,1) MsgBox(0,"test generator",$RandomPick1 & "-" & $RandomPick2 & "-" & $RandomPick3 & "-" & $RandomPick4 & "-" & $RandomPick5)oÝ÷ ÛhÊ°j{ZB"ë-§^iìZ^ÁêÞÊ©ë,éÞ«^¶µ§(uëkÊØb²Þjëh×6GuiCreate("generator",466,191,339,224) $button1=GuiCtrlCreateButton("generate",135,63,127,32) GuiSetState() While 1 $msg=GuiGetMsg() If $msg=-3 Then Exit If $msg=$button1 Then button1() Wend Func button1() $one = 1000 $ten = 9999 $RandomPick1 = Random($one,$ten,1) $RandomPick2 = Random($one,$ten,1) $RandomPick3 = Random($one,$ten,1) $RandomPick4 = Random($one,$ten,1) $RandomPick5 = Random($one,$ten,1) MsgBox(0,"code",$RandomPick1 & "-" & $RandomPick2 & "-" & $RandomPick3 & "-" & $RandomPick4 & "-" & $RandomPick5) EndFunc hope it helped! Edited October 11, 2008 by join Link to comment Share on other sites More sharing options...
MrCreatoR Posted October 12, 2008 Share Posted October 12, 2008 How about generate random numbers without duplicates? #include <Array.au3> ;Will generate 5 random numbers, where maximum possible number is 5, and minimum is 1 $aRet = _GenerateRandomNumbers(5, 5, 1) ;This one shows that this function generate really *different* random numbers :) _ArrayDisplay($aRet) ;Will generate 25 random numbers, where maximum possible number is 150, and minimum is 10 $aRet = _GenerateRandomNumbers(25, 150, 10) _ArrayDisplay($aRet) ;$iGenerateNums - Total numbers to generate. ;$iMaxEachNum - Largest number to be generated. ;$iMinEachNum - Smallest number to be generated. ;Note: $iGenerateNums can not be grater than ($iMaxEachNum - $iMinEachNum) + 1 Func _GenerateRandomNumbers($iGenerateNums, $iMaxEachNum, $iMinEachNum=0) If $iGenerateNums > ($iMaxEachNum - $iMinEachNum) + 1 Then Return SetError(1, 0, 0) Local $aRandom[$iGenerateNums] For $i = 0 To $iGenerateNums-1 While 1 $aRandom[$i] = Random($iMinEachNum, $iMaxEachNum, 1) For $j = 0 To $iGenerateNums-1 If $j = $i Then ContinueLoop If $aRandom[$j] = $aRandom[$i] Then ContinueLoop 2 Next ExitLoop WEnd Next Return $aRandom EndFunc Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team Link to comment Share on other sites More sharing options...
join Posted October 12, 2008 Author Share Posted October 12, 2008 it´s not repeting... Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now