Jump to content

List of numbers and checking


Recommended Posts

I made a script in which ended up with alot of numbers in which I will refer to as $numbers, and I have no idea how to make a "list" or an "array" for these numbers. $numbers are then to divide $MainNumb. This divided number is then to compare itself equal to $const. The problem I am having is what command to use for the list or array, could I have some help?

Link to comment
Share on other sites

  • Moderators

As mentioned, there are great tutorials in the help file on using arrays, have you read through them and tried the examples? If you produce some code, or even a more detailed explanation of what you're trying to accomplish, we can probably do more to assist.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

#include <ImageSearch.au3>
#include "FastFind.au3"
#include <GDIPlus.au3>
#include <Array.au3>
HotKeySet("q", "MyExit")
$A1 = 0
$A2 = 0
$A3 = 0
$A4 = 0
$A5 = 0
$B1 = 0
$B2 = 0
$B3 = 0
$B4 = 0
$B5 = 0
$C1 = 0
$C2 = 0
$C3 = 0
$C4 = 0
$C5 = 0
$D1 = 0
$D2 = 0
$D3 = 0
$D4 = 0
$D5 = 0
$E1 = 0
$E2 = 0
$E3 = 0
$E4 = 0
$E5 = 0
Local $Numbers[25] = [$A1, $A2, $A3, $A4, $A5, $B1, $B2, $B3, $B4, $B5, $C1,$C2, $C3, $C4, $C5, $D1, $D2, $D3, $D4, $D5, $E1, $E2, $E3, $E4, $E5]
While $loop <> 5
   $MainNumb = FFColorCount (0x000000, 0, True,655, 576, 697, 604)

   $A1 = FFColorCount (0x000000, 0, True, 550, 233, 600, 263)
   $A2 = FFColorCount (0x000000, 0, True, 550, 279, 600, 318)
   $A3 = FFColorCount (0x000000, 0, True, 550, 327, 600, 361)
   $A4 = FFColorCount (0x000000, 0, True, 550, 384, 600, 414)
   $A5 = FFColorCount (0x000000, 0, True, 550, 427, 600, 463)


   $B1 = FFColorCount (0x000000, 0, True, 600, 233, 650, 263)
   $B2 = FFColorCount (0x000000, 0, True, 600, 279, 650, 318)
   $B3 = FFColorCount (0x000000, 0, True, 600, 327, 650, 361)
   $B4 = FFColorCount (0x000000, 0, True, 600, 384, 650, 414)
   $B5 = FFColorCount (0x000000, 0, True, 600, 427, 650, 463)


   $C1 = FFColorCount (0x000000, 0, True, 650, 233, 700, 263)
   $C2 = FFColorCount (0x000000, 0, True, 650, 279, 700, 318)
   $C3 = FFColorCount (0x000000, 0, True, 650, 327, 700, 361)
   $C4 = FFColorCount (0x000000, 0, True, 650, 384, 700, 414)
   $C5 = FFColorCount (0x000000, 0, True, 650, 427, 700, 463)


   $D1 = FFColorCount (0x000000, 0, True, 700, 233, 750, 263)
   $D2 = FFColorCount (0x000000, 0, True, 700, 279, 750, 318)
   $D3 = FFColorCount (0x000000, 0, True, 700, 327, 750, 361)
   $D4 = FFColorCount (0x000000, 0, True, 700, 384, 750, 414)
   $D5 = FFColorCount (0x000000, 0, True, 700, 427, 750, 463)


   $E1 = FFColorCount (0x000000, 0, True, 750, 233, 800, 263)
   $E2 = FFColorCount (0x000000, 0, True, 750, 279, 800, 318)
   $E3 = FFColorCount (0x000000, 0, True, 750, 327, 800, 361)
   $E4 = FFColorCount (0x000000, 0, True, 750, 384, 800, 414)
   $E5 = FFColorCount (0x000000, 0, True, 750, 427, 800, 463)


   $difference = $MainNumb/$Numbers
   MsgBox(0, "test", $difference)
   Exit
   If $difference == 317/167 Then
   exit
EndIf
WEnd

Func MyExit ()
   Exit
EndFunc

Here's the code, sorry for the mess, but here you can see what I am trying to do. I would not care too much about what the numbers are or how I got them, but the problem is within making the array and making it compare with a constant number. I don't know how I would use an array in this situation, and I would be very happy if someone could tell me if this is the correct use for it, or how to improve on it. I would appreciate if you commented on the whole code, but focus on the main issue as the code does run until the array problems starts to pop up.

Link to comment
Share on other sites

You're not modifying the $Numbers array during your While loop so each item will remain 0, in fact you don't actually need to place the variables into the array since you can just use the array variable example: $Number[0] <-> $Number[25].

I don't have the ImageSearch or FastFind UDFs so what do you thing $Numbers should equal?  I can only assume $MainNumb is a number, so what are you expecting with $MainNumber/$Numbers?  Are you expecting to compare the last item in the array or ??

Link to comment
Share on other sites

I think you mean something like this

;#include <ImageSearch.au3>
;#include "FastFind.au3"
#include <GDIPlus.au3>
#include <Array.au3>
HotKeySet("q", "MyExit")

Local $aNumbers[25]
;With all zeros the same thing would be.. ;$aNumbers[25] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 , 0, 0, 0, 0, 0, 0, 0, 0]


;You could also use enum to have named indices
#cs
    Local Enum $eA1= 0, $eA2, $eA3 $eA4, $eA5, $eB1, $eB2........
    ;$aNumbers[0] is same as $aNumbers[$eA1]
    ;$aNumbers[6] is same as $aNumbers[$eB2]
#ce
Local $iAvg, $iDiff

For $iLoop = 0 To 5
    $MainNumb = FFColorCount(0x000000, 0, True, 655, 576, 697, 604)

    $aNumbers[0] = FFColorCount(0x000000, 0, True, 550, 233, 600, 263)
    $aNumbers[1] = FFColorCount(0x000000, 0, True, 550, 279, 600, 318)
    $aNumbers[2] = FFColorCount(0x000000, 0, True, 550, 327, 600, 361)
    $aNumbers[3] = FFColorCount(0x000000, 0, True, 550, 384, 600, 414)
    $aNumbers[4] = FFColorCount(0x000000, 0, True, 550, 427, 600, 463)


    $aNumbers[5] = FFColorCount(0x000000, 0, True, 600, 233, 650, 263)
    $aNumbers[6] = FFColorCount(0x000000, 0, True, 600, 279, 650, 318)
    $aNumbers[7] = FFColorCount(0x000000, 0, True, 600, 327, 650, 361)
    $aNumbers[8] = FFColorCount(0x000000, 0, True, 600, 384, 650, 414)
    $aNumbers[9] = FFColorCount(0x000000, 0, True, 600, 427, 650, 463)


    $aNumbers[10] = FFColorCount(0x000000, 0, True, 650, 233, 700, 263)
    $aNumbers[11] = FFColorCount(0x000000, 0, True, 650, 279, 700, 318)
    $aNumbers[12] = FFColorCount(0x000000, 0, True, 650, 327, 700, 361)
    $aNumbers[13] = FFColorCount(0x000000, 0, True, 650, 384, 700, 414)
    $aNumbers[14] = FFColorCount(0x000000, 0, True, 650, 427, 700, 463)


    $aNumbers[15] = FFColorCount(0x000000, 0, True, 700, 233, 750, 263)
    $aNumbers[16] = FFColorCount(0x000000, 0, True, 700, 279, 750, 318)
    $aNumbers[17] = FFColorCount(0x000000, 0, True, 700, 327, 750, 361)
    $aNumbers[18] = FFColorCount(0x000000, 0, True, 700, 384, 750, 414)
    $aNumbers[19] = FFColorCount(0x000000, 0, True, 700, 427, 750, 463)


    $aNumbers[20] = FFColorCount(0x000000, 0, True, 750, 233, 800, 263)
    $aNumbers[21] = FFColorCount(0x000000, 0, True, 750, 279, 800, 318)
    $aNumbers[22] = FFColorCount(0x000000, 0, True, 750, 327, 800, 361)
    $aNumbers[23] = FFColorCount(0x000000, 0, True, 750, 384, 800, 414)
    $aNumbers[24] = FFColorCount(0x000000, 0, True, 750, 427, 800, 463)

    For $i = 0 To UBound($aNumbers) - 1 ; arrays are zero based
        $iAvg += $aNumbers[$i] ;Have to access each individual item in an array
    Next

    $iAvg /= (UBound($aNumbers))
    $iDiff = $MainNumb / $iAvg
    MsgBox(0, "test", $MainNumb & " / " & $iAvg & " = " & $iDiff)


    If $iDiff == 317 / 167 Then
        MyExit()
    EndIf
Next

;Just a dummy function to test with
Func FFColorCount($a, $b, $c, $d, $e, $f, $g)
    Local Static $x = 1000
    $x -= 25
    Return $x
EndFunc   ;==>FFColorCount

Func MyExit()
    Exit
EndFunc   ;==>MyExit

 

Link to comment
Share on other sites

8 hours ago, Subz said:

I don't have the ImageSearch or FastFind UDFs so what do you thing $Numbers should equal?  I can only assume $MainNumb is a number, so what are you expecting with $MainNumber/$Numbers?  Are you expecting to compare the last item in the array or ??

$MainNumb is a number in which counts the amounts of pixels of a certain color (black int this case) on a part of my monitor, $Numbers is then the array in which contains a list of values, the $A(-E)1(-5) numbers. The $A(-E)1(-5) numbers contains the amount of pixels in the same color of $MainNumb. The $Numbers and $MainNumb have a chance to be the same picture, but they are in a different size, therefore I have a constant $difference. so if $MainNumb/$Numbers == $difference, then it would mean that it has the same picture.

 

If that made any sense.

Link to comment
Share on other sites

7 hours ago, Bilgus said:

I think you mean something like this

;#include <ImageSearch.au3>
;#include "FastFind.au3"
#include <GDIPlus.au3>
#include <Array.au3>
HotKeySet("q", "MyExit")

Local $aNumbers[25]
;With all zeros the same thing would be.. ;$aNumbers[25] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 , 0, 0, 0, 0, 0, 0, 0, 0]


;You could also use enum to have named indices
#cs
    Local Enum $eA1= 0, $eA2, $eA3 $eA4, $eA5, $eB1, $eB2........
    ;$aNumbers[0] is same as $aNumbers[$eA1]
    ;$aNumbers[6] is same as $aNumbers[$eB2]
#ce
Local $iAvg, $iDiff

For $iLoop = 0 To 5
    $MainNumb = FFColorCount(0x000000, 0, True, 655, 576, 697, 604)

    $aNumbers[0] = FFColorCount(0x000000, 0, True, 550, 233, 600, 263)
    $aNumbers[1] = FFColorCount(0x000000, 0, True, 550, 279, 600, 318)
    $aNumbers[2] = FFColorCount(0x000000, 0, True, 550, 327, 600, 361)
    $aNumbers[3] = FFColorCount(0x000000, 0, True, 550, 384, 600, 414)
    $aNumbers[4] = FFColorCount(0x000000, 0, True, 550, 427, 600, 463)


    $aNumbers[5] = FFColorCount(0x000000, 0, True, 600, 233, 650, 263)
    $aNumbers[6] = FFColorCount(0x000000, 0, True, 600, 279, 650, 318)
    $aNumbers[7] = FFColorCount(0x000000, 0, True, 600, 327, 650, 361)
    $aNumbers[8] = FFColorCount(0x000000, 0, True, 600, 384, 650, 414)
    $aNumbers[9] = FFColorCount(0x000000, 0, True, 600, 427, 650, 463)


    $aNumbers[10] = FFColorCount(0x000000, 0, True, 650, 233, 700, 263)
    $aNumbers[11] = FFColorCount(0x000000, 0, True, 650, 279, 700, 318)
    $aNumbers[12] = FFColorCount(0x000000, 0, True, 650, 327, 700, 361)
    $aNumbers[13] = FFColorCount(0x000000, 0, True, 650, 384, 700, 414)
    $aNumbers[14] = FFColorCount(0x000000, 0, True, 650, 427, 700, 463)


    $aNumbers[15] = FFColorCount(0x000000, 0, True, 700, 233, 750, 263)
    $aNumbers[16] = FFColorCount(0x000000, 0, True, 700, 279, 750, 318)
    $aNumbers[17] = FFColorCount(0x000000, 0, True, 700, 327, 750, 361)
    $aNumbers[18] = FFColorCount(0x000000, 0, True, 700, 384, 750, 414)
    $aNumbers[19] = FFColorCount(0x000000, 0, True, 700, 427, 750, 463)


    $aNumbers[20] = FFColorCount(0x000000, 0, True, 750, 233, 800, 263)
    $aNumbers[21] = FFColorCount(0x000000, 0, True, 750, 279, 800, 318)
    $aNumbers[22] = FFColorCount(0x000000, 0, True, 750, 327, 800, 361)
    $aNumbers[23] = FFColorCount(0x000000, 0, True, 750, 384, 800, 414)
    $aNumbers[24] = FFColorCount(0x000000, 0, True, 750, 427, 800, 463)

    For $i = 0 To UBound($aNumbers) - 1 ; arrays are zero based
        $iAvg += $aNumbers[$i] ;Have to access each individual item in an array
    Next

    $iAvg /= (UBound($aNumbers))
    $iDiff = $MainNumb / $iAvg
    MsgBox(0, "test", $MainNumb & " / " & $iAvg & " = " & $iDiff)


    If $iDiff == 317 / 167 Then
        MyExit()
    EndIf
Next

;Just a dummy function to test with
Func FFColorCount($a, $b, $c, $d, $e, $f, $g)
    Local Static $x = 1000
    $x -= 25
    Return $x
EndFunc   ;==>FFColorCount

Func MyExit()
    Exit
EndFunc   ;==>MyExit

 

That is exactly what I was looking to do, thanks!

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...