Jump to content

Please how can I return a random number to ControlSend() function - (Locked)


Go to solution Solved by argumentum,

Recommended Posts

Posted
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.

Posted
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.
autoit_scripter_blue_userbar.png

Posted

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

 

Global $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
Posted (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 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.
  :)

Guest
This topic is now closed to further replies.
×
×
  • Create New...