MariusN Posted May 1, 2013 Share Posted May 1, 2013 Hi folks...I have a script with about 6 + functions in them that gets activated by pressing ONE button in a while/wend loop. This $Button has a function that it calls .i.e. Start()... the Start() now calls OTHER functions .i.e. Start2(), Start3(), etc, ...each doing its own thing... Sometimes (from within a function ), i need to RE-press the $Button variable to give me a certain result. Is there a way to RE-press the $Button WITHIN a function, WITHOUT having to "click" on the button again? (basically i want the button to be pressed by itself) PS: ALL my functions are outside my while-wend tia Link to comment Share on other sites More sharing options...
MariusN Posted May 1, 2013 Author Share Posted May 1, 2013 I was thinking....I'll rather try and do a while/wend WITHIN all my functions with an @error....and see what happpens Link to comment Share on other sites More sharing options...
PhoenixXL Posted May 1, 2013 Share Posted May 1, 2013 can you give us the code you have so far. My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 1, 2013 Moderators Share Posted May 1, 2013 MariusN,Is there a way to RE-press the $Button WITHIN a function, WITHOUT having to "click" on the button again? (basically i want the button to be pressed by itself)You do not need to "press" the button itself - just carry out the actions that would occur if the button were pressed. But using the same button to do many things can lead to all sorts of problems if you do not end the currently running function before starting the new one. If you were to post your code we might be able to help you produce something that does not turn into spaghetti after a few clicks. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
MariusN Posted May 1, 2013 Author Share Posted May 1, 2013 MariusN,You do not need to "press" the button itself - just carry out the actions that would occur if the button were pressed. But using the same button to do many things can lead to all sorts of problems if you do not end the currently running function before starting the new one. If you were to post your code we might be able to help you produce something that does not turn into spaghetti after a few clicks. M23Hi M23...thats exactly what i have done...execute the "code" of the function, but i get a "Recursion level has been exceeded" sometimes...I was thinking of doing a do/until in my functions...and see what happens Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 1, 2013 Moderators Share Posted May 1, 2013 MariusN,i get a "Recursion level has been exceeded" sometimesExactly what I was referring to above! So post the code and we will try and untangle it for you. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
MariusN Posted May 1, 2013 Author Share Posted May 1, 2013 (edited) here is my code. Basicly, every time i "hit" a button, it wil go to the next function. It gets the no's ($i) from a "For $i = 1 To 49 Step 1"-loop. Sometimes the SAME no get thrown out, but i need to RErun the function IF the no already exists...WITHOUT having to press my $Start button ($Start starts the opperation btw ) expandcollapse popupFunc start1($depth) $a = GUICtrlRead($input1) ;reads "# of inpurbox If $a = "" Then ;check the inputbox has # $test = GUICtrlSetData($input1, $i) $tester1 = GUICtrlRead($input1) ;the # in input box Else start2($depth) EndIf EndFunc ;==>start1 Func start2($depth) $a2 = GUICtrlRead($input2);reads "# of inpurbox If $a2 = "" Then; If $i <> $tester1 Then GUICtrlSetData($input2, $i) $tester2 = GUICtrlRead($input2) Else [color=#ff0000];<---I need to put something here[/color] EndIf Else start3($depth) EndIf EndFunc ;==>start2 Func start3($depth) $a3 = GUICtrlRead($input3);reads "# of inpurbox If $a3 = "" Then;check the inputbox has # If $i <> $tester1 And $i <> $tester2 Then GUICtrlSetData($input3, $i) $tester3 = GUICtrlRead($input3) Else [color=#ff0000];<-----I need to put something here[/color] EndIf Else start4($depth) EndIf EndFunc ;==>start3 Func start4($depth) $a4 = GUICtrlRead($input4) If $a4 = "" Then If $i <> $tester1 And $i <> $tester2 And $i <> $tester3 Then GUICtrlSetData($input4, $i) $tester4 = GUICtrlRead($input4) Else [color=#ff0000];<---I need to put something here[/color] EndIf Else start5($depth) EndIf EndFunc ;==>start4 Func start5($depth) $a5 = GUICtrlRead($input5) If $a5 = "" Then If $i <> $tester1 And $i <> $tester2 And $i <> $tester3 And $i <> $tester4 Then GUICtrlSetData($input5, $i) $tester5 = GUICtrlRead($input5) Else [color=#ff0000];<---I need to put something here[/color] EndIf Else start6($depth) EndIf EndFunc ;==>start5 Func start6($depth) $a6 = GUICtrlRead($input6) If $a6 <> "" Then $msg1 = MsgBox(0x4, " CHECK!!!", "Clear current Settings?") If $msg1 = 6 Then GUICtrlSetData($input1, "") GUICtrlSetData($input2, "") GUICtrlSetData($input3, "") GUICtrlSetData($input4, "") GUICtrlSetData($input5, "") GUICtrlSetData($input6, "") Else EndIf EndIf If $a6 = "" Then If $i <> $tester1 And $i <> $tester2 And $i <> $tester3 And $i <> $tester4 And $i <> $tester5 Then GUICtrlSetData($input6, $i) $tester6 = GUICtrlRead($input6) Else [color=#ff0000];<---I need to put something here[/color] EndIf EndIf EndFunc ;==>start6 Edited May 1, 2013 by MariusN Changed to autoit tags Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 1, 2013 Moderators Share Posted May 1, 2013 MariusN,Can you please post the rest of the code. What you have posted shows exactly why you run into recursion problems, but does not give too many clues as to exactly how we can resolve the problem. In principle, you need to conclude each function and return a value from it to the main loop where you decide if you need to run the next. But without seeing that main loop it is difficult to code it so that it all integrates correctly. M23P.S. When you post code please use AutoIt tags - put [autoit] before and [/autoit] after your posted code. Then you get a scrolling box and syntax colouring as you can see above now I have added them. MariusN 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
MariusN Posted May 1, 2013 Author Share Posted May 1, 2013 (edited) GUISetState() While 1 For $i = 1 To 49 Step 1 Sleep(10) $MSG = GUIGetMsg() Select Case $MSG = $GUI_EVENT_CLOSE Exit Case $MSG = $BUTTON_1 start1($depth) EndSelect Next WEnd Edited May 1, 2013 by MariusN Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 1, 2013 Moderators Share Posted May 1, 2013 MariusN,No wonder you were having problems! What on earth is all that about? Firstly, I am not going to write all the additional code to add a GUI and several inputs so that the code actually runs - so I suggest you post ALL the code if you want help. Secondly, what exactly do you want to happen in that loop? At the moment I am not at all sure that what you think is happening is what the code is doing. Nor am I at all clear what you are doing in those functions. How about some clear explanation of what you are trying to achieve so that we can develop something logical which does what you want. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
MariusN Posted May 1, 2013 Author Share Posted May 1, 2013 (edited) this is a lotto generator...What "baffles" MY mind is, whenever the program gets the SAME no, you can just RE-HIT $button_1...and it will work. Thing is, i DONT want to re-hit the $button_1, it must do so by itself. IF i do a "start1($depth)" after the ELSE...i get the "recursion"-error expandcollapse popup#region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=lotto.ico #AutoIt3Wrapper_outfile=lotto.exe #AutoIt3Wrapper_Run_Obfuscator=y #Obfuscator_Parameters=/striponly #endregion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstantsEx.au3> #include <Array.au3> #include <WindowsConstants.au3> FileInstall("games_128.ico", @ScriptDir & "\", 1) ;FileInstall("games_256.ico", @ScriptDir & "\bin\", 0) Opt("MustDeclareVars", 1) Opt("GUICloseOnESC", 1) Global $aNumbers[6], $gui Local $MSG, $BUTTON_1, $var1, $var, $i, $test, $input1, $input2, $input3, $input4, $input5, $input6, $read1, $2, $RegName, $open Local $no1, $no6, $BUTTON_3, $a, $a1, $a2, $a3, $a4, $a5, $iNumber, $BUTTON_2, $background, $aa, $tester1, $tester2 Local $tester3, $tester4, $tester5, $tester6, $a6, $label1, $font, $author, $msg1, $open1, $read2, $read3 Local $file = "Registration.txt" Local $depth = 0 ;$open1 = FileOpen($file, 0) ;$read2 = FileRead($open1) ;If $read2 = "Nico Gouws" Then ;Else ; $input1 = InputBox("Please type your Name", "Enter your Name", "", " M10", "", 50) ; If $input1 = "Nico Gouws" Then ; $open = FileOpen($file, 1) ; $read3 = FileWrite($open, $input1) ; FileClose($open) ; Else ; MsgBox(0, "", "Closing Program!") ; Exit ; EndIf ;EndIf $gui = GUICreate("Lotto-Generator v1.00", 380, 130) GUICtrlCreateIcon("games_128.ico", "name", 290, 50, 60, 60) $BUTTON_2 = GUICtrlCreateButton(" Quick Pick! ", 10, 10, -1, -1);,$BS_ICON) GUISetBkColor(0x999999) $font = "Arial";"Times New Roman" $label1 = GUICtrlCreateLabel("Good Luck!!!", 140, 90, 100, 40) GUICtrlSetFont(-1, 11, 600, 0, $font) $author = GUICtrlCreateLabel("Author's Homepage", 10, 90, 100, 40) GUICtrlSetColor(-1, 0x3333FF) GUICtrlSetFont(-1, 11, 600, 6, $font) GUICtrlSetCursor(-1, 0) $BUTTON_1 = GUICtrlCreateButton(" YOUR Luck! ", 10, 50, -1, -1) $BUTTON_3 = GUICtrlCreateButton(" Clear All! ", 160, 50, -1, -1) $input1 = GUICtrlCreateInput("", 100, 10, 20, 20) $input2 = GUICtrlCreateInput("", 150, 10, 20, 20) $input3 = GUICtrlCreateInput("", 200, 10, 20, 20) $input4 = GUICtrlCreateInput("", 250, 10, 20, 20) $input5 = GUICtrlCreateInput("", 300, 10, 20, 20) $input6 = GUICtrlCreateInput("", 350, 10, 20, 20) GUISetState() While 1 For $i = 1 To 49 Step 1 Sleep(10) $MSG = GUIGetMsg() Select Case $MSG = $GUI_EVENT_CLOSE Exit Case $MSG = $BUTTON_1 start1($depth) Case $MSG = $BUTTON_2 For $i = 0 To 5 Do $iNumber = Random(1, 49, 1) Until _ArraySearch($aNumbers, $iNumber) = -1 $aNumbers[$i] = $iNumber Next GUICtrlSetData($input1, ($aNumbers[0])) GUICtrlSetData($input2, ($aNumbers[1])) GUICtrlSetData($input3, ($aNumbers[2])) GUICtrlSetData($input4, ($aNumbers[3])) GUICtrlSetData($input5, ($aNumbers[4])) GUICtrlSetData($input6, ($aNumbers[5])) Case $MSG = $BUTTON_3 GUICtrlSetData($input1, "") GUICtrlSetData($input2, "") GUICtrlSetData($input3, "") GUICtrlSetData($input4, "") GUICtrlSetData($input5, "") GUICtrlSetData($input6, "") EndSelect Next WEnd Func start1($depth) $a = GUICtrlRead($input1) ;reads "# of inpurbox If $a = "" Then ;check the inputbox has # $test = GUICtrlSetData($input1, $i) $tester1 = GUICtrlRead($input1) ;the # in input box Else start2($depth) EndIf EndFunc ;==>start1 Func start2($depth) $a2 = GUICtrlRead($input2);reads "# of inpurbox If $a2 = "" Then; If $i <> $tester1 Then GUICtrlSetData($input2, $i) $tester2 = GUICtrlRead($input2) Else Do Sleep(10) Until $i <> $tester1 GUICtrlSetData($input2, $i) EndIf Else start3($depth) EndIf EndFunc ;==>start2 Func start3($depth) $a3 = GUICtrlRead($input3);reads "# of inpurbox If $a3 = "" Then;check the inputbox has # If $i <> $tester1 And $i <> $tester2 Then GUICtrlSetData($input3, $i) $tester3 = GUICtrlRead($input3) Else Do Sleep(10) Until $i <> $tester1 And $i <> $tester2 GUICtrlSetData($input3, $i) EndIf Else start4($depth) EndIf EndFunc ;==>start3 Func start4($depth) $a4 = GUICtrlRead($input4) If $a4 = "" Then If $i <> $tester1 And $i <> $tester2 And $i <> $tester3 Then GUICtrlSetData($input4, $i) $tester4 = GUICtrlRead($input4) Else Do Sleep(10) Until $i <> $tester1 And $i <> $tester2 And $i <> $tester3 GUICtrlSetData($input4, $i) EndIf Else start5($depth) EndIf EndFunc ;==>start4 Func start5($depth) $a5 = GUICtrlRead($input5) If $a5 = "" Then If $i <> $tester1 And $i <> $tester2 And $i <> $tester3 And $i <> $tester4 Then GUICtrlSetData($input5, $i) $tester5 = GUICtrlRead($input5) Else Do Sleep(10) Until $i <> $tester1 And $i <> $tester2 And $i <> $tester3 And $i <> $tester4 GUICtrlSetData($input5, $i) EndIf Else start6($depth) EndIf EndFunc ;==>start5 Func start6($depth) $a6 = GUICtrlRead($input6) If $a6 = "" Then If $i <> $tester1 And $i <> $tester2 And $i <> $tester3 And $i <> $tester4 And $i <> $tester5 Then GUICtrlSetData($input6, $i) $tester6 = GUICtrlRead($input6) Else Do Sleep(10) Until $i <> $tester1 And $i <> $tester2 And $i <> $tester3 And $i <> $tester4 And $i <> $tester5 GUICtrlSetData($input6, $i) EndIf EndIf If $a6 <> "" Or $a6 = @error Then $msg1 = MsgBox(0x4, " CHECK!!!", "Clear current Settings?") If $msg1 = 6 Then GUICtrlSetData($input1, "") GUICtrlSetData($input2, "") GUICtrlSetData($input3, "") GUICtrlSetData($input4, "") GUICtrlSetData($input5, "") GUICtrlSetData($input6, "") EndIf EndIf EndFunc ;==>start6 Edited May 1, 2013 by MariusN Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 1, 2013 Moderators Share Posted May 1, 2013 MariusN, A couple of questions: - Why are you looping 49 times? Do you want the script to exit after 49 attempts? - I can see what the "QUICKPICK" button does, but what exactly are the "YourLuck" button and all those functions supposed to do? Are they supposed to check the current values against some form of "correct" answer? If so, where is the "corerct" answer stored? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
MariusN Posted May 1, 2013 Author Share Posted May 1, 2013 (edited) MariusN,A couple of questions: - Why are you looping 49 times? Do you want the script to exit after 49 attempts?- I can see what the "QUICKPICK" button does, but what exactly are the "YourLuck" button and all those functions supposed to do? Are they supposed to check the current values against some form of "correct" answer? If so, where is the "corerct" answer stored?M23hi Melba...The LOOP kicks out numbers...meaning....if you "pause" , the loop continues...and as soon as you "hit" the button, it will grab the number currently availible in the loop ($i) and put it in the next "availible" box...It so happens, that sometimes the SAME number is being grabbed as is in a previous box...if this happens ( while the loop still runs in the background ) i want the program to automaticly grab the next "availible" no, and put it i the next availible box...THATS where my problem resides...the ARRAY button works 100%. The reason behind this idea, is to give a guy a chance by picking no's that he feels was chosen by himself....because....the longer you wait, the more "different" the no when you hit $BUTTON_1 this makes the "picking" more interestingPS: if i put a "Return" between ELSE and ENDIF, i sometimes get this "recursing"-error. Thing is...everytime you HIT the button, it will ALWAYS start from the first function...ie "start1($depth)"What i cant understand is, if i hit the button again (if the SAME no is catched), i get NO recursion error....only when i do e return or call the first function "start1($depth)" AGAIN ( which is exactly what the NORMAL button does, only WITHOUT errors)....seems like a "time"-issue... Edited May 1, 2013 by MariusN Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 1, 2013 Moderators Share Posted May 1, 2013 MariusN, Got it! M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 1, 2013 Moderators Share Posted May 1, 2013 MariusN, Take a look at this: expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=lotto.ico #AutoIt3Wrapper_outfile=lotto.exe #AutoIt3Wrapper_Run_Obfuscator=y #Obfuscator_Parameters=/striponly #Endregion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstantsEx.au3> #include <Array.au3> #include <WindowsConstants.au3> FileInstall("games_128.ico", @ScriptDir & "\", 1) ;FileInstall("games_256.ico", @ScriptDir & "\bin\", 0) Opt("MustDeclareVars", 1) Opt("GUICloseOnESC", 1) Global $sFont = "Arial";"Times New Roman" Global $aInput[6], $aNumbers[6], $aYourLuck[6] Global $iNumber, $iYourLuck_Number = 0, $iYourLuck_Input = 0, $iCurrNumber Global $hGUI = GUICreate("Lotto-Generator v1.00", 380, 130) ;GUICtrlCreateIcon("games_128.ico", "name", 290, 50, 60, 60) Global $cButton_QuickPick = GUICtrlCreateButton(" Quick Pick! ", 10, 10, -1, -1);,$BS_ICON) GUISetBkColor(0x999999) GUICtrlCreateLabel("Good Luck!!!", 140, 90, 100, 40) GUICtrlSetFont(-1, 11, 600, 0, $sFont) Global $cButton_YourLuck = GUICtrlCreateButton(" YOUR Luck! ", 10, 50, -1, -1) Global $cButton_Clear = GUICtrlCreateButton(" Clear All! ", 160, 50, -1, -1) Global $cAuthor = GUICtrlCreateLabel("Author's Homepage", 10, 90, 100, 40) GUICtrlSetColor(-1, 0x3333FF) GUICtrlSetFont(-1, 11, 600, 6, $sFont) GUICtrlSetCursor(-1, 0) For $i = 0 To 5 $aInput[$i] = GUICtrlCreateInput("", 100 + (50 * $i), 10, 20, 20) Next GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cButton_QuickPick ; Choose 6 unique random number For $i = 0 To 5 Do $iNumber = Random(1, 49, 1) Until _ArraySearch($aNumbers, $iNumber) = -1 ; Add to array $aNumbers[$i] = $iNumber Next ; Sort them into order <<<<<<<<<<<<<<<<<<<<<<< only if you wish to do this _ArraySort($aNumbers) ; Place in inputs For $i = 0 To 5 GUICtrlSetData($aInput[$i], $aNumbers[$i]) Next Case $cButton_Clear ; Loop through the inputs For $i = 0 To 5 GUICtrlSetData($aInput[$i], "") Next ; Reset the "YourLuck" data $iYourLuck_Number = 0 $iYourLuck_Input = 0 Global $aYourLuck Case $cButton_YourLuck ; Check of all inputs filled If $iYourLuck_Input <> 6 Then ; Get current YourLuck number $iCurrNumber = $iYourLuck_Number ; Check it is unique While _ArraySearch($aYourLuck, $iCurrNumber) <> -1 ; Increase in range 1-49 if not $iCurrNumber = Mod($iCurrNumber, 49) + 1 WEnd ; Add to array $aYourLuck[$iYourLuck_Input] = $iCurrNumber ; And add to input GUICtrlSetData($aInput[$iYourLuck_Input], $iCurrNumber) ; Move to next input $iYourLuck_Input += 1 EndIf EndSwitch ; Increase the YourLuck variable in the range 1-49 $iYourLuck_Number = Mod($iYourLuck_Number, 49) + 1 WEnd Please ask if you have any questions about why I have done things the way I have. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
MariusN Posted May 1, 2013 Author Share Posted May 1, 2013 MariusN, Take a look at this: expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=lotto.ico #AutoIt3Wrapper_outfile=lotto.exe #AutoIt3Wrapper_Run_Obfuscator=y #Obfuscator_Parameters=/striponly #Endregion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstantsEx.au3> #include <Array.au3> #include <WindowsConstants.au3> FileInstall("games_128.ico", @ScriptDir & "\", 1) ;FileInstall("games_256.ico", @ScriptDir & "\bin\", 0) Opt("MustDeclareVars", 1) Opt("GUICloseOnESC", 1) Global $sFont = "Arial";"Times New Roman" Global $aInput[6], $aNumbers[6], $aYourLuck[6] Global $iNumber, $iYourLuck_Number = 0, $iYourLuck_Input = 0, $iCurrNumber Global $hGUI = GUICreate("Lotto-Generator v1.00", 380, 130) ;GUICtrlCreateIcon("games_128.ico", "name", 290, 50, 60, 60) Global $cButton_QuickPick = GUICtrlCreateButton(" Quick Pick! ", 10, 10, -1, -1);,$BS_ICON) GUISetBkColor(0x999999) GUICtrlCreateLabel("Good Luck!!!", 140, 90, 100, 40) GUICtrlSetFont(-1, 11, 600, 0, $sFont) Global $cButton_YourLuck = GUICtrlCreateButton(" YOUR Luck! ", 10, 50, -1, -1) Global $cButton_Clear = GUICtrlCreateButton(" Clear All! ", 160, 50, -1, -1) Global $cAuthor = GUICtrlCreateLabel("Author's Homepage", 10, 90, 100, 40) GUICtrlSetColor(-1, 0x3333FF) GUICtrlSetFont(-1, 11, 600, 6, $sFont) GUICtrlSetCursor(-1, 0) For $i = 0 To 5 $aInput[$i] = GUICtrlCreateInput("", 100 + (50 * $i), 10, 20, 20) Next GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cButton_QuickPick ; Choose 6 unique random number For $i = 0 To 5 Do $iNumber = Random(1, 49, 1) Until _ArraySearch($aNumbers, $iNumber) = -1 ; Add to array $aNumbers[$i] = $iNumber Next ; Sort them into order <<<<<<<<<<<<<<<<<<<<<<< only if you wish to do this _ArraySort($aNumbers) ; Place in inputs For $i = 0 To 5 GUICtrlSetData($aInput[$i], $aNumbers[$i]) Next Case $cButton_Clear ; Loop through the inputs For $i = 0 To 5 GUICtrlSetData($aInput[$i], "") Next ; Reset the "YourLuck" data $iYourLuck_Number = 0 $iYourLuck_Input = 0 Global $aYourLuck Case $cButton_YourLuck ; Check of all inputs filled If $iYourLuck_Input <> 6 Then ; Get current YourLuck number $iCurrNumber = $iYourLuck_Number ; Check it is unique While _ArraySearch($aYourLuck, $iCurrNumber) <> -1 ; Increase in range 1-49 if not $iCurrNumber = Mod($iCurrNumber, 49) + 1 WEnd ; Add to array $aYourLuck[$iYourLuck_Input] = $iCurrNumber ; And add to input GUICtrlSetData($aInput[$iYourLuck_Input], $iCurrNumber) ; Move to next input $iYourLuck_Input += 1 EndIf EndSwitch ; Increase the YourLuck variable in the range 1-49 $iYourLuck_Number = Mod($iYourLuck_Number, 49) + 1 WEnd Please ask if you have any questions about why I have done things the way I have. M23 i have just used "AutoItSetOption ("SendKeyDelay")" and it seemed to work ...I'll try yours as well....thx Malba Link to comment Share on other sites More sharing options...
MariusN Posted May 1, 2013 Author Share Posted May 1, 2013 (edited) Geez....Yours work like a CHARM...and such a small script?...cant believe it....thx anyways PS: i'll rather use YOURS....lolol Edited May 1, 2013 by MariusN Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 1, 2013 Moderators Share Posted May 1, 2013 MariusN, I am pleased you like it. Do try and understand how it works so that you use some of the tricks in your own scripts. And of course do ask if you have any questions. M23 MariusN 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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