Cypharr Posted January 30, 2024 Posted January 30, 2024 While 1 ;loop indefinitely Global $iRandom ; Declare a variable - to store the random numbers $iRandom = Random(1, 4, 1) ControlSend("","","","$iRandom",1) Sleep(1000) ;Sleep 1 seconds WEnd The $iRandom variable is not returning a random number between 1 & 4. Instead the function is reading the $iRandom variable as a string I think.
Solution argumentum Posted January 30, 2024 Solution Posted January 30, 2024 ControlSend("","","","$iRandom",1) should be ControlSend("","","",$iRandom,1) otherwise "$iRandom" is a text instead of the variable $iRandom holding the value. Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
Cypharr Posted January 30, 2024 Author Posted January 30, 2024 Please if you don't mind can you also help with how to make the $iRandom not repeat?
argumentum Posted January 30, 2024 Posted January 30, 2024 1 minute ago, Cypharr said: help with how to make the $iRandom not repeat read about SRandom( Seed ). But in any case, random is just random. But if you read about it is just a calculation based on time (AFAIR). And a random of 1,2,3,4 is easily bound to repeat a lot. Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
argumentum Posted January 30, 2024 Posted January 30, 2024 test() Func test() Local $iLastRandom, $iRandom = Random(1, 4, 1) ; Declare a variable - to store the random numbers While 1 ; loop indefinitely ;ControlSend("","","",$iRandom,1) ;Sleep(1000) ;Sleep 1 seconds ConsoleWrite($iRandom & ',') Sleep(100) ;Sleep 100 mSec. SRandom(@MSEC & @SEC) $iLastRandom = $iRandom Do $iRandom = Random(1, 4, 1) Until $iLastRandom <> $iRandom WEnd EndFunc this will skip the repeats Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
Cypharr Posted January 30, 2024 Author Posted January 30, 2024 Looks really complicated. I was able to get ahead but now the issue is I want it to give me 10 random numbers and then sleep for 1 minutes in a loop. However what I've is giving random number but 5 consecutive same number before and random 5 consecutive numbers. Please here is what I've expandcollapse popupGlobal $Min = 1 ; Declare a variable - to store the random numbers Global $Max = 5 ; Declare a variable - to store the random numbers Global $Reset = 0 ; Declare a variable - to store the random numbers Global $RandomA ; Declare a variable - to store the random numbers Global $RandomASleep ; Declare a variable - to store the random numbers Global $RandomSleep ; Declare a variable - to store the random numbers Message() Func Message() While 1 ;loop indefinitely $RandomA = Random($Min, $Max, 1) $RandomASleep = Random(800, 1200) $RandomSleep = Random(55000, 60000) If($RandomA <> $Reset) Then ControlSend("[CLASS:Notepad]","","",$RandomA,1) $Reset = $RandomA Sleep($RandomASleep) ;Sleep ControlSend("[CLASS:Notepad]","","",$RandomA,1) $Reset = $RandomA Sleep($RandomASleep) ;Sleep ControlSend("[CLASS:Notepad]","","",$RandomA,1) $Reset = $RandomA Sleep($RandomASleep) ;Sleep ControlSend("[CLASS:Notepad]","","",$RandomA,1) $Reset = $RandomA Sleep($RandomASleep) ;Sleep ControlSend("[CLASS:Notepad]","","",$RandomA,1) $Reset = $RandomA Sleep($RandomASleep) ;Sleep ControlSend("[CLASS:Notepad]","","",$RandomA,1) $Reset = $RandomA Sleep($RandomASleep) ;Sleep ControlSend("[CLASS:Notepad]","","",$RandomA,1) $Reset = $RandomA Sleep($RandomASleep) ;Sleep EndIf Sleep($RandomSleep) ;Sleep WEnd EndFunc This is the result I'm getting. 11111122222221111111555555511111113333333111111155555554444444111111155555553333333111111155555553333333555555
Developers Jos Posted January 30, 2024 Developers Posted January 30, 2024 (edited) Second warning and consider this the last! Unfortunately you appear to have missed the Forum rules on your way in. Please read them now - particularly the bit about not discussing game automation - and then you will understand why you will get no help and this thread will now be locked. See you soon with a legitimate question I hope. The Moderation team Edited January 30, 2024 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Recommended Posts