xxaviarxx Posted December 12, 2015 Share Posted December 12, 2015 (edited) Here is the code I currently have ::expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 140, 229, 357, 248) $Input1 = GUICtrlCreateInput("0", 8, 14, 123, 28, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER,$ES_READONLY,$ES_NUMBER)) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $Input2 = GUICtrlCreateInput("0", 8, 49, 123, 28, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER,$ES_READONLY,$ES_NUMBER)) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $Input3 = GUICtrlCreateInput("0", 8, 84, 123, 28, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER,$ES_READONLY,$ES_NUMBER)) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $Input4 = GUICtrlCreateInput("0", 8, 120, 123, 28, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER,$ES_READONLY,$ES_NUMBER)) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $Input5 = GUICtrlCreateInput("0", 8, 155, 123, 28, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER,$ES_READONLY,$ES_NUMBER)) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $Button1 = GUICtrlCreateButton("Randomize", 8, 190, 123, 28) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Global $TimesTaken = 0 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 Randomize() EndSwitch WEnd Func Randomize() GUICtrlSetData($Input1, Random(0, 100, 1)) GUICtrlSetData($Input2, Random(0, 100, 1)) GUICtrlSetData($Input3, Random(0, 100, 1)) GUICtrlSetData($Input4, Random(0, 100, 1)) GUICtrlSetData($Input5, Random(0, 100, 1)) If Not ($Input1 And $Input2 And $Input3 And $Input4 And $Input5 = 100) Then $TimesTaken = $TimesTaken + 1 Randomize() Else MsgBox(0, "Times Taken", "Times taken to reach 100 in all Input boxes :: " & $TimesTaken) ConsoleWrite("Times taken to reach 100 in all Input boxes :: " & $TimesTaken) EndIf EndFunc If i am guessing right the reason I am getting that error is because I am looping an IF statement, so my question is which looping statement can I use to achieve the exact same effect as I am trying to do with the IF statement and how do I go about that? I am just doing this for sake of pure boredom and curiosity. Finished Code (Updated based on comments below)::expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> HotKeySet("{ESC}", "Terminate") #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Random", 140, 229, 357, 248) $Input1 = GUICtrlCreateInput("0", 8, 14, 123, 28, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_READONLY, $ES_NUMBER)) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $Input2 = GUICtrlCreateInput("0", 8, 49, 123, 28, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_READONLY, $ES_NUMBER)) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $Input3 = GUICtrlCreateInput("0", 8, 84, 123, 28, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_READONLY, $ES_NUMBER)) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $Input4 = GUICtrlCreateInput("0", 8, 120, 123, 28, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_READONLY, $ES_NUMBER)) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $Input5 = GUICtrlCreateInput("0", 8, 155, 123, 28, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_READONLY, $ES_NUMBER)) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $Button1 = GUICtrlCreateButton("Randomize", 8, 190, 123, 28) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Global $TimesTaken1 = 0 Global $TimesTaken2 = 0 Global $TimesTaken3 = 0 Global $TimesTaken4 = 0 Global $TimesTaken5 = 0 Global $Min = 0 Global $Max = 100 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 Randomize() EndSwitch WEnd Func Randomize() Do GUICtrlSetData($Input1, Random($Min, $Max, 1)) GUICtrlSetData($Input2, Random($Min, $Max, 1)) GUICtrlSetData($Input3, Random($Min, $Max, 1)) GUICtrlSetData($Input4, Random($Min, $Max, 1)) GUICtrlSetData($Input5, Random($Min, $Max, 1)) $Check1 = GUICtrlRead($Input1) = 100 Or GUICtrlRead($Input2) = 100 Or GUICtrlRead($Input3) = 100 Or GUICtrlRead($Input4) = 100 Or GUICtrlRead($Input5) = 100 $TimesTaken1 += 1 Until $Check1 $Check1 = $TimesTaken1 ConsoleWrite("[ " & GUICtrlRead($Input1) & " ] [ " & GUICtrlRead($Input2) & " ] [ " & GUICtrlRead($Input3) & " ] [ " & GUICtrlRead($Input4) & " ] [ " & GUICtrlRead($Input5) & " ]" & @CRLF) ConsoleWrite("Times Taken for 1 input :: " & $Check1 & @CRLF) Do GUICtrlSetData($Input1, Random($Min, $Max, 1)) GUICtrlSetData($Input2, Random($Min, $Max, 1)) GUICtrlSetData($Input3, Random($Min, $Max, 1)) GUICtrlSetData($Input4, Random($Min, $Max, 1)) GUICtrlSetData($Input5, Random($Min, $Max, 1)) $Check2 = (GUICtrlRead($Input1) = 100 And GUICtrlRead($Input2) = 100) Or (GUICtrlRead($Input1) = 100 And GUICtrlRead($Input3) = 100) Or (GUICtrlRead($Input1) = 100 And GUICtrlRead($Input4) = 100) Or (GUICtrlRead($Input1) = 100 And GUICtrlRead($Input5) = 100) Or (GUICtrlRead($Input2) = 100 And GUICtrlRead($Input3) = 100) Or (GUICtrlRead($Input2) = 100 And GUICtrlRead($Input4) = 100) Or (GUICtrlRead($Input2) = 100 And GUICtrlRead($Input5) = 100) Or (GUICtrlRead($Input3) = 100 And GUICtrlRead($Input4) = 100) Or (GUICtrlRead($Input3) = 100 And GUICtrlRead($Input5) = 100) Or (GUICtrlRead($Input4) = 100 And GUICtrlRead($Input5) = 100) $TimesTaken2 += 1 Until $Check2 $Check2 = $TimesTaken2 ConsoleWrite("[ " & GUICtrlRead($Input1) & " ] [ " & GUICtrlRead($Input2) & " ] [ " & GUICtrlRead($Input3) & " ] [ " & GUICtrlRead($Input4) & " ] [ " & GUICtrlRead($Input5) & " ]" & @CRLF) ConsoleWrite("Times Taken for 2 inputs :: " & $Check2 & @CRLF) Do GUICtrlSetData($Input1, Random($Min, $Max, 1)) GUICtrlSetData($Input2, Random($Min, $Max, 1)) GUICtrlSetData($Input3, Random($Min, $Max, 1)) GUICtrlSetData($Input4, Random($Min, $Max, 1)) GUICtrlSetData($Input5, Random($Min, $Max, 1)) $Check3 = (GUICtrlRead($Input1) = 100 And GUICtrlRead($Input2) = 100 And GUICtrlRead($Input3) = 100) Or (GUICtrlRead($Input1) = 100 And GUICtrlRead($Input2) = 100 And GUICtrlRead($Input4) = 100) Or (GUICtrlRead($Input1) = 100 And GUICtrlRead($Input2) = 100 And GUICtrlRead($Input5) = 100) Or (GUICtrlRead($Input1) = 100 And GUICtrlRead($Input3) = 100 And GUICtrlRead($Input4) = 100) Or (GUICtrlRead($Input1) = 100 And GUICtrlRead($Input3) = 100 And GUICtrlRead($Input5) = 100) Or (GUICtrlRead($Input1) = 100 And GUICtrlRead($Input4) = 100 And GUICtrlRead($Input5) = 100) Or (GUICtrlRead($Input2) = 100 And GUICtrlRead($Input3) = 100 And GUICtrlRead($Input4) = 100) Or (GUICtrlRead($Input2) = 100 And GUICtrlRead($Input3) = 100 And GUICtrlRead($Input5) = 100) Or (GUICtrlRead($Input2) = 100 And GUICtrlRead($Input4) = 100 And GUICtrlRead($Input5) = 100) Or (GUICtrlRead($Input3) = 100 And GUICtrlRead($Input4) = 100 And GUICtrlRead($Input5) = 100) $TimesTaken3 += 1 Until $Check3 $Check3 = $TimesTaken3 ConsoleWrite("[ " & GUICtrlRead($Input1) & " ] [ " & GUICtrlRead($Input2) & " ] [ " & GUICtrlRead($Input3) & " ] [ " & GUICtrlRead($Input4) & " ] [ " & GUICtrlRead($Input5) & " ]" & @CRLF) ConsoleWrite("Times Taken for 3 inputs :: " & $Check3 & @CRLF) Do GUICtrlSetData($Input1, Random($Min, $Max, 1)) GUICtrlSetData($Input2, Random($Min, $Max, 1)) GUICtrlSetData($Input3, Random($Min, $Max, 1)) GUICtrlSetData($Input4, Random($Min, $Max, 1)) GUICtrlSetData($Input5, Random($Min, $Max, 1)) $Check4 = (GUICtrlRead($Input1) = 100 And GUICtrlRead($Input2) = 100 And GUICtrlRead($Input3) = 100 And GUICtrlRead($Input4) = 100) Or (GUICtrlRead($Input1) = 100 And GUICtrlRead($Input2) = 100 And GUICtrlRead($Input3) = 100 And GUICtrlRead($Input5) = 100) Or (GUICtrlRead($Input1) = 100 And GUICtrlRead($Input3) = 100 And GUICtrlRead($Input4) = 100 And GUICtrlRead($Input5) = 100) Or (GUICtrlRead($Input2) = 100 And GUICtrlRead($Input3) = 100 And GUICtrlRead($Input4) = 100 And GUICtrlRead($Input5) = 100) $TimesTaken4 += 1 Until $Check4 $Check4 = $TimesTaken4 ConsoleWrite("[ " & GUICtrlRead($Input1) & " ] [ " & GUICtrlRead($Input2) & " ] [ " & GUICtrlRead($Input3) & " ] [ " & GUICtrlRead($Input4) & " ] [ " & GUICtrlRead($Input5) & " ]" & @CRLF) ConsoleWrite("Times Taken for 4 inputs :: " & $Check4 & @CRLF) Do GUICtrlSetData($Input1, Random($Min, $Max, 1)) GUICtrlSetData($Input2, Random($Min, $Max, 1)) GUICtrlSetData($Input3, Random($Min, $Max, 1)) GUICtrlSetData($Input4, Random($Min, $Max, 1)) GUICtrlSetData($Input5, Random($Min, $Max, 1)) $Check5 = GUICtrlRead($Input1) = 100 And GUICtrlRead($Input2) = 100 And GUICtrlRead($Input3) = 100 And GUICtrlRead($Input4) = 100 And GUICtrlRead($Input5) = 100 $TimesTaken5 += 1 Until $Check5 $Check5 = $TimesTaken5 ConsoleWrite("[ " & GUICtrlRead($Input1) & " ] [ " & GUICtrlRead($Input2) & " ] [ " & GUICtrlRead($Input3) & " ] [ " & GUICtrlRead($Input4) & " ] [ " & GUICtrlRead($Input5) & " ]" & @CRLF) ConsoleWrite("Times Taken for 5 inputs :: " & $Check5 & @CRLF) MsgBox(0, "Times Taken", "Times taken to reach 100 in 1 Input Box :: " & $Check1 & @CRLF & "Times taken to reach 100 in 2 Input Boxes :: " & $Check2 & @CRLF & "Times taken to reach 100 in 3 Input Boxes :: " & $Check3 & @CRLF & "Times taken to reach 100 in 4 Input Boxes :: " & $Check4 & @CRLF & "Times taken to reach 100 in 5 Input Boxes :: " & $Check5 & @CRLF) EndFunc ;==>Randomize Func Terminate() If WinActive($Form1) Then Exit EndFunc ;==>Terminate Edited December 12, 2015 by xxaviarxx Link to comment Share on other sites More sharing options...
Danyfirex Posted December 12, 2015 Share Posted December 12, 2015 This never will be false Not ($Input1 And $Input2 And $Input3 And $Input4 And $Input5 = 100) Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
xxaviarxx Posted December 12, 2015 Author Share Posted December 12, 2015 How will it never be false when If Not is the same thing as saying <> for not equal to, unless I completely misread one of Melba's previous posts on the forum in which he said he prefers using <> instead of If Not because it will cause less confusion or something to that effect anyway. Link to comment Share on other sites More sharing options...
JohnOne Posted December 12, 2015 Share Posted December 12, 2015 It's unlikely that inputs 1, 2, 3, and 4 will be 0 at the same time. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
xxaviarxx Posted December 12, 2015 Author Share Posted December 12, 2015 I'm wanting to find out the odds in getting 5 inputs all randomly generated to 100, however unlikely that may be. Link to comment Share on other sites More sharing options...
Danyfirex Posted December 12, 2015 Share Posted December 12, 2015 you're comparing control ID not control data. Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
Gianni Posted December 12, 2015 Share Posted December 12, 2015 better don't use recursion in this case...,you could use a way like this instead(I've limited the checking to only the first 2 controls, just remove the semicolon to extend the check to all 5 controls)... good luckexpandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> HotKeySet("{ESC}", "Terminate") #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 140, 229, 357, 248) $Input1 = GUICtrlCreateInput("0", 8, 14, 123, 28, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_READONLY, $ES_NUMBER)) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $Input2 = GUICtrlCreateInput("0", 8, 49, 123, 28, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_READONLY, $ES_NUMBER)) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $Input3 = GUICtrlCreateInput("0", 8, 84, 123, 28, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_READONLY, $ES_NUMBER)) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $Input4 = GUICtrlCreateInput("0", 8, 120, 123, 28, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_READONLY, $ES_NUMBER)) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $Input5 = GUICtrlCreateInput("0", 8, 155, 123, 28, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_READONLY, $ES_NUMBER)) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $Button1 = GUICtrlCreateButton("Randomize", 8, 190, 123, 28) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Global $TimesTaken = 0 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $iTimesTaken = Randomize() ConsoleWrite("Times taken to reach 100 in all Input boxes :: " & Int($iTimesTaken / 1000) & " Sec.") ; time given in seconds MsgBox(0, "Times Taken", "Times taken to reach 100 in all Input boxes :: " & Int($iTimesTaken) & " millisec.") ; time given in milliseconds EndSwitch WEnd Func Randomize() Local $TimesTaken = TimerInit() Do GUICtrlSetData($Input1, Random(0, 100, 1)) GUICtrlSetData($Input2, Random(0, 100, 1)) GUICtrlSetData($Input3, Random(0, 100, 1)) GUICtrlSetData($Input4, Random(0, 100, 1)) GUICtrlSetData($Input5, Random(0, 100, 1)) $bCheck = GUICtrlRead($Input1) = 100 And GUICtrlRead($Input2) = 100 ; And GUICtrlRead($Input3) = 100 And GUICtrlRead($Input4) = 100 And GUICtrlRead($Input5) = 100 Until $bCheck Return TimerDiff($TimesTaken) EndFunc ;==>Randomize Func Terminate() If WinActive($Form1) Then Exit EndFunc ;==>Terminate Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
junkew Posted December 12, 2015 Share Posted December 12, 2015 I assume even with a while loop the $TimesTaken will overflow. I would be weird of 5 times on a row you get 100 FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
JohnOne Posted December 12, 2015 Share Posted December 12, 2015 I think working the odds out is a mathematical problem that can be dome with some simple calculations, not actually testing those odds.It might be only 125 million to 1, and still not occur within a year of your script running.So you might want to set aside some time. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
xxaviarxx Posted December 12, 2015 Author Share Posted December 12, 2015 (edited) Thank you Chimp for helping me figure out which Loop system to use to bypass the Recursion limits as well as the hotkey idea. Thank you DanyFireX for hinting, which I completely missed until Chimp's code (complete blonde moment), that I didn't use GUICtrlRead to read the values of my inputs.Here is the finished result of the script, hopefully I didn't miss anything, of course it more than likely could have been done in a neater way and without redundancies ::expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> HotKeySet("{ESC}", "Terminate") #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Random", 140, 229, 357, 248) $Input1 = GUICtrlCreateInput("0", 8, 14, 123, 28, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_READONLY, $ES_NUMBER)) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $Input2 = GUICtrlCreateInput("0", 8, 49, 123, 28, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_READONLY, $ES_NUMBER)) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $Input3 = GUICtrlCreateInput("0", 8, 84, 123, 28, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_READONLY, $ES_NUMBER)) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $Input4 = GUICtrlCreateInput("0", 8, 120, 123, 28, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_READONLY, $ES_NUMBER)) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $Input5 = GUICtrlCreateInput("0", 8, 155, 123, 28, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_READONLY, $ES_NUMBER)) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $Button1 = GUICtrlCreateButton("Randomize", 8, 190, 123, 28) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Global $TimesTaken1 = 0 Global $TimesTaken2 = 0 Global $TimesTaken3 = 0 Global $TimesTaken4 = 0 Global $TimesTaken5 = 0 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 Randomize() EndSwitch WEnd Func Randomize() Do GUICtrlSetData($Input1, Random(0, 100, 1)) GUICtrlSetData($Input2, Random(0, 100, 1)) GUICtrlSetData($Input3, Random(0, 100, 1)) GUICtrlSetData($Input4, Random(0, 100, 1)) GUICtrlSetData($Input5, Random(0, 100, 1)) $Check1 = GUICtrlRead($Input1) = 100 Or GUICtrlRead($Input2) = 100 Or GUICtrlRead($Input3) = 100 Or GUICtrlRead($Input4) = 100 Or GUICtrlRead($Input5) = 100 $TimesTaken1 += 1 Until $Check1 $Check1 = $TimesTaken1 ConsoleWrite("Times Taken for 1 input :: " & $Check1 & @CRLF) Do GUICtrlSetData($Input1, Random(0, 100, 1)) GUICtrlSetData($Input2, Random(0, 100, 1)) GUICtrlSetData($Input3, Random(0, 100, 1)) GUICtrlSetData($Input4, Random(0, 100, 1)) GUICtrlSetData($Input5, Random(0, 100, 1)) $Check2 = (GUICtrlRead($Input1) = 100 And GUICtrlRead($Input2) = 100) Or (GUICtrlRead($Input1) = 100 And GUICtrlRead($Input3) = 100) Or (GUICtrlRead($Input1) = 100 And GUICtrlRead($Input4) = 100) Or (GUICtrlRead($Input1) = 100 And GUICtrlRead($Input5) = 100) Or (GUICtrlRead($Input2) = 100 And GUICtrlRead($Input3) = 100) Or (GUICtrlRead($Input2) = 100 And GUICtrlRead($Input4) = 100) Or (GUICtrlRead($Input2) = 100 And GUICtrlRead($Input5) = 100) Or (GUICtrlRead($Input3) = 100 And GUICtrlRead($Input4) = 100) Or (GUICtrlRead($Input3) = 100 And GUICtrlRead($Input5) = 100) Or (GUICtrlRead($Input4) = 100 And GUICtrlRead($Input5) = 100) $TimesTaken2 += 1 Until $Check2 $Check2 = $TimesTaken2 ConsoleWrite("Times Taken for 2 inputs :: " & $Check2 & @CRLF) Do GUICtrlSetData($Input1, Random(0, 100, 1)) GUICtrlSetData($Input2, Random(0, 100, 1)) GUICtrlSetData($Input3, Random(0, 100, 1)) GUICtrlSetData($Input4, Random(0, 100, 1)) GUICtrlSetData($Input5, Random(0, 100, 1)) $Check3 = (GUICtrlRead($Input1) = 100 And GUICtrlRead($Input2) = 100 And GUICtrlRead($Input3) = 100) Or (GUICtrlRead($Input1) = 100 And GUICtrlRead($Input2) = 100 And GUICtrlRead($Input4) = 100) Or (GUICtrlRead($Input1) = 100 And GUICtrlRead($Input2) = 100 And GUICtrlRead($Input5) = 100) Or (GUICtrlRead($Input1) = 100 And GUICtrlRead($Input3) = 100 And GUICtrlRead($Input4) = 100) Or (GUICtrlRead($Input1) = 100 And GUICtrlRead($Input3) = 100 And GUICtrlRead($Input5) = 100) Or (GUICtrlRead($Input1) = 100 And GUICtrlRead($Input4) = 100 And GUICtrlRead($Input5) = 100) Or (GUICtrlRead($Input2) = 100 And GUICtrlRead($Input3) = 100 And GUICtrlRead($Input4) = 100) Or (GUICtrlRead($Input2) = 100 And GUICtrlRead($Input3) = 100 And GUICtrlRead($Input5) = 100) Or (GUICtrlRead($Input2) = 100 And GUICtrlRead($Input4) = 100 And GUICtrlRead($Input5) = 100) Or (GUICtrlRead($Input3) = 100 And GUICtrlRead($Input4) = 100 And GUICtrlRead($Input5) = 100) $TimesTaken3 += 1 Until $Check3 $Check3 = $TimesTaken3 ConsoleWrite("Times Taken for 3 inputs :: " & $Check3 & @CRLF) Do GUICtrlSetData($Input1, Random(0, 100, 1)) GUICtrlSetData($Input2, Random(0, 100, 1)) GUICtrlSetData($Input3, Random(0, 100, 1)) GUICtrlSetData($Input4, Random(0, 100, 1)) GUICtrlSetData($Input5, Random(0, 100, 1)) $Check4 = (GUICtrlRead($Input1) = 100 And GUICtrlRead($Input2) = 100 And GUICtrlRead($Input3) = 100 And GUICtrlRead($Input4) = 100) Or (GUICtrlRead($Input1) = 100 And GUICtrlRead($Input2) = 100 And GUICtrlRead($Input3) = 100 And GUICtrlRead($Input5) = 100) Or (GUICtrlRead($Input1) = 100 And GUICtrlRead($Input3) = 100 And GUICtrlRead($Input4) = 100 And GUICtrlRead($Input5) = 100) Or (GUICtrlRead($Input2) = 100 And GUICtrlRead($Input3) = 100 And GUICtrlRead($Input4) = 100 And GUICtrlRead($Input5) = 100) $TimesTaken4 += 1 Until $Check4 $Check4 = $TimesTaken4 ConsoleWrite("Times Taken for 4 inputs :: " & $Check4 & @CRLF) Do GUICtrlSetData($Input1, Random(0, 100, 1)) GUICtrlSetData($Input2, Random(0, 100, 1)) GUICtrlSetData($Input3, Random(0, 100, 1)) GUICtrlSetData($Input4, Random(0, 100, 1)) GUICtrlSetData($Input5, Random(0, 100, 1)) $Check5 = GUICtrlRead($Input1) = 100 And GUICtrlRead($Input2) = 100 And GUICtrlRead($Input3) = 100 And GUICtrlRead($Input4) = 100 And GUICtrlRead($Input5) = 100 $TimesTaken5 += 1 Until $Check5 $Check5 = $TimesTaken5 ConsoleWrite("Times Taken for 5 inputs :: " & $Check5 & @CRLF) MsgBox(0, "Times Taken", "Times taken to reach 100 in 1 Input Box :: " & $Check1 & @CRLF & "Times taken to reach 100 in 2 Input Boxes :: " & $Check2 & @CRLF & "Times taken to reach 100 in 3 Input Boxes :: " & $Check3 & @CRLF & "Times taken to reach 100 in 4 Input Boxes :: " & $Check4 & @CRLF & "Times taken to reach 100 in 5 Input Boxes :: " & $Check5 & @CRLF) EndFunc ;==>Randomize Func Terminate() If WinActive($Form1) Then Exit EndFunc ;==>Terminate@JohnOne Rationally thinking 100^5 would be the chances of hitting 100 in all 5 input boxes at the same time which is about 10 billion to 1 odds (if my math is correct), but as I was bored I wanted to make a script for this. Edited December 12, 2015 by xxaviarxx Link to comment Share on other sites More sharing options...
Bowmore Posted December 12, 2015 Share Posted December 12, 2015 It might be only 125 million to 1, and still not occur within a year of your script running.Assuming Autoit could populate 5 controlls with random numbers in the range 1 to 100 once every 10 milliseconds, Then with continuous running the on average getting all 5 set to 100 should happen about once every 3 years "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook Link to comment Share on other sites More sharing options...
JohnOne Posted December 12, 2015 Share Posted December 12, 2015 lolcare to share the math behind that AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
xxaviarxx Posted December 12, 2015 Author Share Posted December 12, 2015 (edited) Assuming Autoit could populate 5 controlls with random numbers in the range 1 to 100 once every 10 milliseconds, Then with continuous running the on average getting all 5 set to 100 should happen about once every 3 years lolcare to share the math behind that I'd also love to hear the math behind that one as well seeing as I can get 3/5 in under, well under, 20 minutes. Edited December 12, 2015 by xxaviarxx Link to comment Share on other sites More sharing options...
junkew Posted December 12, 2015 Share Posted December 12, 2015 (edited) At least for yathzee from 1 to 6 you can throw the same valuesModified your example. From 0 to 100 I only had it once for 4 but so far never reached 5 in a row46;71;15;92;100Times Taken for 1 input :: 8 check 1100;43;0;86;100Times Taken for 2 input :: 1860 check 250;100;100;100;6Times Taken for 3 input :: 28261 check 3100;100;16;100;100Times Taken for 4 input :: 3862263 check 4expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> HotKeySet("{ESC}", "Terminate") #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Random", 140, 229, 357, 248) $Input1 = GUICtrlCreateInput("0", 8, 14, 123, 28, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_READONLY, $ES_NUMBER)) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $Input2 = GUICtrlCreateInput("0", 8, 49, 123, 28, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_READONLY, $ES_NUMBER)) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $Input3 = GUICtrlCreateInput("0", 8, 84, 123, 28, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_READONLY, $ES_NUMBER)) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $Input4 = GUICtrlCreateInput("0", 8, 120, 123, 28, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_READONLY, $ES_NUMBER)) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $Input5 = GUICtrlCreateInput("0", 8, 155, 123, 28, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_READONLY, $ES_NUMBER)) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $Button1 = GUICtrlCreateButton("Randomize", 8, 190, 123, 28) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Global $TimesTaken1 = 0 Global $TimesTaken2 = 0 Global $TimesTaken3 = 0 Global $TimesTaken4 = 0 Global $TimesTaken5 = 0 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 Randomize() EndSwitch WEnd Func Randomize() dim $iMaxSame dim $vInput[5] const $minVal=0 const $maxVal=100 ;dicevalues ;const $minVal=1 ;const $maxVal=6 for $iMaxSame=1 to 5 $timestaken=0 Do $check=0 $vInput[0]= Random($minVal, $maxVal, 1) $vInput[1]= Random($minVal, $maxVal, 1) $vInput[2]= Random($minVal, $maxVal, 1) $vInput[3]= Random($minVal, $maxVal, 1) $vInput[4]= Random($minVal, $maxVal, 1) if $vInput[0]=$maxVal then $check+=1 if $vInput[1]=$maxVal then $check+=1 if $vInput[2]=$maxVal then $check+=1 if $vInput[3]=$maxVal then $check+=1 if $vInput[4]=$maxVal then $check+=1 $TimesTaken += 1 until $Check>=$iMaxSame guictrlsetdata($Input1,$vInput[0]) guictrlsetdata($Input2,$vInput[1]) guictrlsetdata($Input3,$vInput[2]) guictrlsetdata($Input4,$vInput[3]) guictrlsetdata($Input5,$vInput[4]) consolewrite($vInput[0] & ";" & $vInput[1] & ";" & $vInput[2]& ";" & $vInput[3] & ";" & $vInput[4] & @crlf) ConsoleWrite("Times Taken for " & $iMaxSame & " input :: " & $TimesTaken & " check " & $check & @CRLF) Next EndFunc ;==>Randomize Func Terminate() If WinActive($Form1) Then Exit EndFunc ;==>Terminate Edited December 12, 2015 by junkew FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
xxaviarxx Posted December 12, 2015 Author Share Posted December 12, 2015 At least for yathzee from 1 to 6 you can throw the same valuesModified your example. From 0 to 100 I only had it once for 4 but so far never reached 5 in a rowexpandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> HotKeySet("{ESC}", "Terminate") #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Random", 140, 229, 357, 248) $Input1 = GUICtrlCreateInput("0", 8, 14, 123, 28, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_READONLY, $ES_NUMBER)) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $Input2 = GUICtrlCreateInput("0", 8, 49, 123, 28, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_READONLY, $ES_NUMBER)) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $Input3 = GUICtrlCreateInput("0", 8, 84, 123, 28, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_READONLY, $ES_NUMBER)) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $Input4 = GUICtrlCreateInput("0", 8, 120, 123, 28, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_READONLY, $ES_NUMBER)) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $Input5 = GUICtrlCreateInput("0", 8, 155, 123, 28, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_READONLY, $ES_NUMBER)) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $Button1 = GUICtrlCreateButton("Randomize", 8, 190, 123, 28) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Global $TimesTaken1 = 0 Global $TimesTaken2 = 0 Global $TimesTaken3 = 0 Global $TimesTaken4 = 0 Global $TimesTaken5 = 0 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 Randomize() EndSwitch WEnd Func Randomize() dim $iMaxSame dim $vInput[5] const $minVal=0 const $maxVal=100 ;dicevalues ;const $minVal=1 ;const $maxVal=6 for $iMaxSame=1 to 5 $timestaken=0 Do $check=0 $vInput[0]= Random($minVal, $maxVal, 1) $vInput[1]= Random($minVal, $maxVal, 1) $vInput[2]= Random($minVal, $maxVal, 1) $vInput[3]= Random($minVal, $maxVal, 1) $vInput[4]= Random($minVal, $maxVal, 1) if $vInput[0]=$maxVal then $check+=1 if $vInput[1]=$maxVal then $check+=1 if $vInput[2]=$maxVal then $check+=1 if $vInput[3]=$maxVal then $check+=1 if $vInput[4]=$maxVal then $check+=1 $TimesTaken += 1 until $Check>=$iMaxSame guictrlsetdata($Input1,$vInput[0]) guictrlsetdata($Input2,$vInput[1]) guictrlsetdata($Input3,$vInput[2]) guictrlsetdata($Input4,$vInput[3]) guictrlsetdata($Input5,$vInput[4]) consolewrite($vInput[0] & ";" & $vInput[1] & ";" & $vInput[2]& ";" & $vInput[3] & ";" & $vInput[4] & @crlf) ConsoleWrite("Times Taken for " & $iMaxSame & " input :: " & $TimesTaken & " check " & $check & @CRLF) Next EndFunc ;==>Randomize Func Terminate() If WinActive($Form1) Then Exit EndFunc ;==>Terminate The condensing is real O_O. In fact it is so condensed that I cannot tell what at all is going on but assuming from your post it works exactly like mine does. I haven't reached 4 in a row yet but I just started the script like 5 minutes ago after initial testing before posting the finished script. Link to comment Share on other sites More sharing options...
junkew Posted December 12, 2015 Share Posted December 12, 2015 I changed the script to put it in arrayvalues with speeds up tremendouslyonly with a match of the max value I count how many are equal to max (I was interested in dices from 1 to 6 so easily change the constants to see what happens for dices)Only when there is a match I change the textboxes and print them to the consolewindowYour original post started with a requirement to see all boxes to become 100. The actual script now calculates 1 out of 5 beeing maxvalue (which is 100)2 out of 5 beeing ......5 out of 5 beeing maxvalue FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
xxaviarxx Posted December 12, 2015 Author Share Posted December 12, 2015 (edited) I changed the script to put it in arrayvalues with speeds up tremendouslyonly with a match of the max value I count how many are equal to max (I was interested in dices from 1 to 6 so easily change the constants to see what happens for dices)Only when there is a match I change the textboxes and print them to the consolewindowYour original post started with a requirement to see all boxes to become 100. The actual script now calculates 1 out of 5 beeing maxvalue (which is 100)2 out of 5 beeing ......5 out of 5 beeing maxvalueMy boredom and curiosity increased reason the script increased to 5 different calculations. I think your condensed version is pretty awesome, I was sitting here wondering how to make it show up which box outputted what number and your script solved that curious notion. Edit:: Really the only downside, which is just something I liked to see about my script vs your script, is that it calculates everything in the background instead of showing all the numbers actually being randomized. Edited December 12, 2015 by xxaviarxx Link to comment Share on other sites More sharing options...
xxaviarxx Posted December 12, 2015 Author Share Posted December 12, 2015 (edited) Updated my code to this (ideas from junkew's comments) ::expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> HotKeySet("{ESC}", "Terminate") #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Random", 140, 229, 357, 248) $Input1 = GUICtrlCreateInput("0", 8, 14, 123, 28, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_READONLY, $ES_NUMBER)) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $Input2 = GUICtrlCreateInput("0", 8, 49, 123, 28, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_READONLY, $ES_NUMBER)) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $Input3 = GUICtrlCreateInput("0", 8, 84, 123, 28, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_READONLY, $ES_NUMBER)) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $Input4 = GUICtrlCreateInput("0", 8, 120, 123, 28, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_READONLY, $ES_NUMBER)) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $Input5 = GUICtrlCreateInput("0", 8, 155, 123, 28, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_READONLY, $ES_NUMBER)) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $Button1 = GUICtrlCreateButton("Randomize", 8, 190, 123, 28) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Global $TimesTaken1 = 0 Global $TimesTaken2 = 0 Global $TimesTaken3 = 0 Global $TimesTaken4 = 0 Global $TimesTaken5 = 0 Global $Min = 0 Global $Max = 100 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 Randomize() EndSwitch WEnd Func Randomize() Do GUICtrlSetData($Input1, Random($Min, $Max, 1)) GUICtrlSetData($Input2, Random($Min, $Max, 1)) GUICtrlSetData($Input3, Random($Min, $Max, 1)) GUICtrlSetData($Input4, Random($Min, $Max, 1)) GUICtrlSetData($Input5, Random($Min, $Max, 1)) $Check1 = GUICtrlRead($Input1) = 100 Or GUICtrlRead($Input2) = 100 Or GUICtrlRead($Input3) = 100 Or GUICtrlRead($Input4) = 100 Or GUICtrlRead($Input5) = 100 $TimesTaken1 += 1 Until $Check1 $Check1 = $TimesTaken1 ConsoleWrite("[ " & GUICtrlRead($Input1) & " ] [ " & GUICtrlRead($Input2) & " ] [ " & GUICtrlRead($Input3) & " ] [ " & GUICtrlRead($Input4) & " ] [ " & GUICtrlRead($Input5) & " ]" & @CRLF) ConsoleWrite("Times Taken for 1 input :: " & $Check1 & @CRLF) Do GUICtrlSetData($Input1, Random($Min, $Max, 1)) GUICtrlSetData($Input2, Random($Min, $Max, 1)) GUICtrlSetData($Input3, Random($Min, $Max, 1)) GUICtrlSetData($Input4, Random($Min, $Max, 1)) GUICtrlSetData($Input5, Random($Min, $Max, 1)) $Check2 = (GUICtrlRead($Input1) = 100 And GUICtrlRead($Input2) = 100) Or (GUICtrlRead($Input1) = 100 And GUICtrlRead($Input3) = 100) Or (GUICtrlRead($Input1) = 100 And GUICtrlRead($Input4) = 100) Or (GUICtrlRead($Input1) = 100 And GUICtrlRead($Input5) = 100) Or (GUICtrlRead($Input2) = 100 And GUICtrlRead($Input3) = 100) Or (GUICtrlRead($Input2) = 100 And GUICtrlRead($Input4) = 100) Or (GUICtrlRead($Input2) = 100 And GUICtrlRead($Input5) = 100) Or (GUICtrlRead($Input3) = 100 And GUICtrlRead($Input4) = 100) Or (GUICtrlRead($Input3) = 100 And GUICtrlRead($Input5) = 100) Or (GUICtrlRead($Input4) = 100 And GUICtrlRead($Input5) = 100) $TimesTaken2 += 1 Until $Check2 $Check2 = $TimesTaken2 ConsoleWrite("[ " & GUICtrlRead($Input1) & " ] [ " & GUICtrlRead($Input2) & " ] [ " & GUICtrlRead($Input3) & " ] [ " & GUICtrlRead($Input4) & " ] [ " & GUICtrlRead($Input5) & " ]" & @CRLF) ConsoleWrite("Times Taken for 2 inputs :: " & $Check2 & @CRLF) Do GUICtrlSetData($Input1, Random($Min, $Max, 1)) GUICtrlSetData($Input2, Random($Min, $Max, 1)) GUICtrlSetData($Input3, Random($Min, $Max, 1)) GUICtrlSetData($Input4, Random($Min, $Max, 1)) GUICtrlSetData($Input5, Random($Min, $Max, 1)) $Check3 = (GUICtrlRead($Input1) = 100 And GUICtrlRead($Input2) = 100 And GUICtrlRead($Input3) = 100) Or (GUICtrlRead($Input1) = 100 And GUICtrlRead($Input2) = 100 And GUICtrlRead($Input4) = 100) Or (GUICtrlRead($Input1) = 100 And GUICtrlRead($Input2) = 100 And GUICtrlRead($Input5) = 100) Or (GUICtrlRead($Input1) = 100 And GUICtrlRead($Input3) = 100 And GUICtrlRead($Input4) = 100) Or (GUICtrlRead($Input1) = 100 And GUICtrlRead($Input3) = 100 And GUICtrlRead($Input5) = 100) Or (GUICtrlRead($Input1) = 100 And GUICtrlRead($Input4) = 100 And GUICtrlRead($Input5) = 100) Or (GUICtrlRead($Input2) = 100 And GUICtrlRead($Input3) = 100 And GUICtrlRead($Input4) = 100) Or (GUICtrlRead($Input2) = 100 And GUICtrlRead($Input3) = 100 And GUICtrlRead($Input5) = 100) Or (GUICtrlRead($Input2) = 100 And GUICtrlRead($Input4) = 100 And GUICtrlRead($Input5) = 100) Or (GUICtrlRead($Input3) = 100 And GUICtrlRead($Input4) = 100 And GUICtrlRead($Input5) = 100) $TimesTaken3 += 1 Until $Check3 $Check3 = $TimesTaken3 ConsoleWrite("[ " & GUICtrlRead($Input1) & " ] [ " & GUICtrlRead($Input2) & " ] [ " & GUICtrlRead($Input3) & " ] [ " & GUICtrlRead($Input4) & " ] [ " & GUICtrlRead($Input5) & " ]" & @CRLF) ConsoleWrite("Times Taken for 3 inputs :: " & $Check3 & @CRLF) Do GUICtrlSetData($Input1, Random($Min, $Max, 1)) GUICtrlSetData($Input2, Random($Min, $Max, 1)) GUICtrlSetData($Input3, Random($Min, $Max, 1)) GUICtrlSetData($Input4, Random($Min, $Max, 1)) GUICtrlSetData($Input5, Random($Min, $Max, 1)) $Check4 = (GUICtrlRead($Input1) = 100 And GUICtrlRead($Input2) = 100 And GUICtrlRead($Input3) = 100 And GUICtrlRead($Input4) = 100) Or (GUICtrlRead($Input1) = 100 And GUICtrlRead($Input2) = 100 And GUICtrlRead($Input3) = 100 And GUICtrlRead($Input5) = 100) Or (GUICtrlRead($Input1) = 100 And GUICtrlRead($Input3) = 100 And GUICtrlRead($Input4) = 100 And GUICtrlRead($Input5) = 100) Or (GUICtrlRead($Input2) = 100 And GUICtrlRead($Input3) = 100 And GUICtrlRead($Input4) = 100 And GUICtrlRead($Input5) = 100) $TimesTaken4 += 1 Until $Check4 $Check4 = $TimesTaken4 ConsoleWrite("[ " & GUICtrlRead($Input1) & " ] [ " & GUICtrlRead($Input2) & " ] [ " & GUICtrlRead($Input3) & " ] [ " & GUICtrlRead($Input4) & " ] [ " & GUICtrlRead($Input5) & " ]" & @CRLF) ConsoleWrite("Times Taken for 4 inputs :: " & $Check4 & @CRLF) Do GUICtrlSetData($Input1, Random($Min, $Max, 1)) GUICtrlSetData($Input2, Random($Min, $Max, 1)) GUICtrlSetData($Input3, Random($Min, $Max, 1)) GUICtrlSetData($Input4, Random($Min, $Max, 1)) GUICtrlSetData($Input5, Random($Min, $Max, 1)) $Check5 = GUICtrlRead($Input1) = 100 And GUICtrlRead($Input2) = 100 And GUICtrlRead($Input3) = 100 And GUICtrlRead($Input4) = 100 And GUICtrlRead($Input5) = 100 $TimesTaken5 += 1 Until $Check5 $Check5 = $TimesTaken5 ConsoleWrite("[ " & GUICtrlRead($Input1) & " ] [ " & GUICtrlRead($Input2) & " ] [ " & GUICtrlRead($Input3) & " ] [ " & GUICtrlRead($Input4) & " ] [ " & GUICtrlRead($Input5) & " ]" & @CRLF) ConsoleWrite("Times Taken for 5 inputs :: " & $Check5 & @CRLF) MsgBox(0, "Times Taken", "Times taken to reach 100 in 1 Input Box :: " & $Check1 & @CRLF & "Times taken to reach 100 in 2 Input Boxes :: " & $Check2 & @CRLF & "Times taken to reach 100 in 3 Input Boxes :: " & $Check3 & @CRLF & "Times taken to reach 100 in 4 Input Boxes :: " & $Check4 & @CRLF & "Times taken to reach 100 in 5 Input Boxes :: " & $Check5 & @CRLF) EndFunc ;==>Randomize Func Terminate() If WinActive($Form1) Then Exit EndFunc ;==>Terminate Edited December 12, 2015 by xxaviarxx Link to comment Share on other sites More sharing options...
jchd Posted December 12, 2015 Share Posted December 12, 2015 Less detailed but more CPU-melting:Local $t = TimerInit(), $i Do $i += 1 Until Random(0, 100, 1) + Random(0, 100, 1) + Random(0, 100, 1) + Random(0, 100, 1) + Random(0, 100, 1) = 500 ConsoleWrite("Goal reached in " & TimerDiff($t) / 1000 & " s after " & $i & " iterations." & @LF) This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
junkew Posted December 12, 2015 Share Posted December 12, 2015 (edited) Updated to output every 10.000 calculations, still gives a visual happening and still keeping speedexpandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> HotKeySet("{ESC}", "Terminate") #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Random", 140, 229, 357, 248) $Input1 = GUICtrlCreateInput("0", 8, 14, 123, 28, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_READONLY, $ES_NUMBER)) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $Input2 = GUICtrlCreateInput("0", 8, 49, 123, 28, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_READONLY, $ES_NUMBER)) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $Input3 = GUICtrlCreateInput("0", 8, 84, 123, 28, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_READONLY, $ES_NUMBER)) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $Input4 = GUICtrlCreateInput("0", 8, 120, 123, 28, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_READONLY, $ES_NUMBER)) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $Input5 = GUICtrlCreateInput("0", 8, 155, 123, 28, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_READONLY, $ES_NUMBER)) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $Button1 = GUICtrlCreateButton("Randomize", 8, 190, 123, 28) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Global $TimesTaken = 0 const $minVal=0 const $maxVal=100 dim $vInput[5] ;dicevalues ;const $minVal=1 ;const $maxVal=6 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 Randomize() EndSwitch WEnd Func Randomize() dim $iMaxSame for $iMaxSame=1 to 5 Local $hTimer = TimerInit() ; Begin the timer and store the handle in a variable. $timestaken=0 Do $check=0 $vInput[0]= Random($minVal, $maxVal, 1) $vInput[1]= Random($minVal, $maxVal, 1) $vInput[2]= Random($minVal, $maxVal, 1) $vInput[3]= Random($minVal, $maxVal, 1) $vInput[4]= Random($minVal, $maxVal, 1) ; Output every time a new calculation is done if mod($timesTaken,10000)=0 then guictrlsetdata($Input1,$vInput[0]) guictrlsetdata($Input2,$vInput[1]) guictrlsetdata($Input3,$vInput[2]) guictrlsetdata($Input4,$vInput[3]) guictrlsetdata($Input5,$vInput[4]) endif if $vInput[0]=$maxVal then $check+=1 if $vInput[1]=$maxVal then $check+=1 if $vInput[2]=$maxVal then $check+=1 if $vInput[3]=$maxVal then $check+=1 if $vInput[4]=$maxVal then $check+=1 $TimesTaken += 1 until $Check>=$iMaxSame Local $fDiff = TimerDiff($hTimer) ; Find the difference in time from the previous call of TimerInit. guictrlsetdata($Input1,$vInput[0]) guictrlsetdata($Input2,$vInput[1]) guictrlsetdata($Input3,$vInput[2]) guictrlsetdata($Input4,$vInput[3]) guictrlsetdata($Input5,$vInput[4]) consolewrite($vInput[0] & ";" & $vInput[1] & ";" & $vInput[2]& ";" & $vInput[3] & ";" & $vInput[4] & @crlf) ConsoleWrite("Times Taken for " & $iMaxSame & " input :: " & $TimesTaken & " check " & $check & " timed " & $fDiff & @CRLF) Next EndFunc ;==>Randomize Func Terminate() ConsoleWrite("Times Taken before interrupt input :: " & $TimesTaken & @CRLF) If WinActive($Form1) Then Exit EndFunc ;==>Terminate Edited December 12, 2015 by junkew FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets 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