Jump to content
Sign in to follow this  
Sfikes

[HELP] Random number but not the same, Please help!

Recommended Posts

Sfikes

Hey so basically I made a script that sends different values all the time. The value must be between 1 and 500 in a non-decimal format. The coincidence for sending the same value twice is pretty low but it does happen some times and it's annoying to watch.

So thats why im asking you guys if you have any ideas how I can prevent this? Thanks in advance, you guys are awesome!

While 1
    Send(Random(1, 500, 1))
    Sleep(500)
    Send("{ENTER}")
WEnd
Edited by Sfikes

Share this post


Link to post
Share on other sites
iamtheky

set a variable and check it, then continueloop before any actions if it matches the last random number

$lastrand = 0
$newrand = 0

While 1
    $newrand = Random(1, 500, 1)
    If $newrand = $lastrand Then continueloop
    msgbox(0, '' , $newrand)
    $lastrand = $newrand
    Sleep(500)
WEnd

 


,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites
Exit
#include <array.au3>

Local $array[500]
For $i=0 To 499
    $array[$i] = $i +1
Next
_ArrayDisplay($array)
_ArrayShuffle($array)
_ArrayDisplay($array)
For $i=0 To 499
    Send( $array[$i])
    Sleep(500)
    Send("{ENTER}")
Next
MsgBox(64+262144, Default, "All 500 numbers sent.",0)

#cs
Place the cursor after this line and then press F5 (GO)


#ce

 


My UDFs, Abbrevs and Snippets
If you like my post, just click the like button :) 

Share this post


Link to post
Share on other sites
ThioFoX
Run("notepad.exe")
WinWaitActive("[CLASS:Notepad]")
WinActivate("[CLASS:Notepad]")
HotKeySet("{ESC}", "_Exit") ;Press ESC to exit...


$iMin = 5
$iMax = 500
$sHistoric = "|"
$i = $iMin
While Sleep(1) And $i <= $iMax
    $iRandom = Random($iMin, $iMax, 1)
    If StringInStr($sHistoric, "|" & $iRandom & "|") Then
        ContinueLoop
    Else
        $sHistoric &= $iRandom & "|"
        $i = $i + 1
        ToolTip($i - 1)
        Send($iRandom)
        Send("{ENTER}")
    EndIf
WEnd


Func _Exit()
    Exit
EndFunc   ;==>_Exit

 

Share this post


Link to post
Share on other sites
Sfikes
On 2016-10-13 at 3:09 AM, Exit said:
#include <array.au3>

Local $array[500]
For $i=0 To 499
    $array[$i] = $i +1
Next
_ArrayDisplay($array)
_ArrayShuffle($array)
_ArrayDisplay($array)
For $i=0 To 499
    Send( $array[$i])
    Sleep(500)
    Send("{ENTER}")
Next
MsgBox(64+262144, Default, "All 500 numbers sent.",0)

#cs
Place the cursor after this line and then press F5 (GO)


#ce

 

Hey! Great solution but i want the script to move on at any given time. So for example when clock hits 23:00 this script should not continue and move on to next function

Share this post


Link to post
Share on other sites
AutoBert

Use macros @HOUR, @MIN and  @SEC to solve.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.