Jump to content
Wildpal

Random choosen variable from array

Recommended Posts

I have 2 different variables that i want to be chosen in a random order but never to be picked twice.

#include <Array.au3>

HotKeySet("{ESC}", "Terminate")

Func Terminate()
   Exit 1
EndFunc

   $pose = Random (947, 956)
   $posf = Random (209, 224)

   $posg = Random (993, 1006)
   $posh = Random (213, 221)

Global $array[2]

Global $array [0] = MouseClick("main", $pose, $posf, 1,10)
Global $array [1] = MouseClick("main", $posg, $posh, 1,10)

Func Click()
   random(array)
endfunc

 

Share this post


Link to post
Share on other sites

Not sure what you are asking here and the posted script will finish immediately, so maybe you can post something that show better what you want?

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.
  :)

Share this post


Link to post
Share on other sites
if random(1,1,1) then
   MouseClick("main",$pose,$posf,1,10) "example 1"
   else
   MouseClick("main",$posg,$posh,1,10) "example 2"
   endif

Sorry im not very good at autoit yet. So i was using this, but the problem is i want it to click the first and the second time without duplicating the same click if it makes any sense

Share this post


Link to post
Share on other sites
1 hour ago, Wildpal said:

if it makes any sense

Not really....   I still don't see any code that I could play with and explains your issue.
What are you even trying to do here with this script?

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.
  :)

Share this post


Link to post
Share on other sites

this may not be the most efficient way to do this but it picks all the random numbers and doesn't repeat them. I disabled the mouseclicks so it wasn't clicking everywhere while i was testing it.  

#include <Array.au3>

HotKeySet("{ESC}", "Terminate")

Func Terminate()
   Exit 1
EndFunc
Global $TrackerA,$TrackerB,$countA=0,$countB=0,$boolA,$boolB


dim $array_e[10]
for $x=0 to 9
    $array_e[$x]=$x+947
Next
dim $array_f[16]
for $x=0 to 15
    $array_f[$x]=$x+209
Next


dim $array_g[14]
for $x=0 to 13
    $array_g[$x]=$x+993
    Next

dim $array_h[9]
for $x=0 to 8
    $array_h[$x]=$x+213
Next
$boolA=true
$boolB=true
while 1

$randE=Random(0,9,1)
$randF=Random(0,15,1)
$randG=Random(0,13,1)
$randH=Random(0,8,1)

if IsArray($TrackerA) and $countA<160 Then
for $x=0 to UBound($TrackerA)-1
    if $TrackerA[$x][0]=$randE Then
        if $TrackerA[$x][1]=$randF Then
            $boolA=False
            ExitLoop
        endif
    Else
    $boolA=True
    EndIf

Next
EndIf

if $boolA=True and not IsArray($TrackerA) Then
    Dim $TrackerA[1][2]
    $TrackerA[0][0]=$randE
    $TrackerA[0][1]=$randF
    ;MouseClick("left",$array_e[$randE],$array_f[$randF])
    $countA+=1

ElseIf $boolA=True and IsArray($TrackerA) Then
    ReDim $TrackerA[UBound($TrackerA)+1][2]
    $TrackerA[UBound($TrackerA)-1][0]=$randE
    $TrackerA[UBound($TrackerA)-1][1]=$randF
;MouseClick("left",$array_e[$randE],$array_f[$randF])
    $countA+=1
EndIf

if IsArray($TrackerB) and $countB<126 Then
for $x=0 to UBound($TrackerB)-1
    if $TrackerB[$x][0]=$randG Then
        if $TrackerB[$x][1]=$randH Then
            $boolB=False
            ExitLoop
        endif
    Else
    $boolB=True
    EndIf
Next
EndIf

if $boolB=True and not IsArray($TrackerB) Then
    Dim $TrackerB[1][2]
    $TrackerB[0][0]=$randG
    $TrackerB[0][1]=$randH
    ;MouseClick("left",$array_g[$randG],$array_h[$randH])
    $countB+=1

ElseIf $boolB=True and IsArray($TrackerB) Then
    ReDim $TrackerB[UBound($TrackerB)+1][2]
    $TrackerB[UBound($TrackerB)-1][0]=$randG
    $TrackerB[UBound($TrackerB)-1][1]=$randH
;MouseClick("left",$array_g[$randG],$array_h[$randH])
    $countB+=1
EndIf
$boolA=False
$boolB=False

if $countA>=160 and $countB>=126 Then
    ExitLoop
    EndIf

WEnd
_ArrayDisplay($TrackerA)
_ArrayDisplay($TrackerB)

 

Edited by markyrocks

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

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...