Sign in to follow this  
Followers 0
testmeout

need help with conditional statement

6 posts in this topic

I am needing some help figuring out how to code a conditional based on checksums. I am new to autoit and have figured out somethings but still have lots of questions.Here is my question

I have calculated the checksums for several locations on an image, and want to assign the same value for several different checksums and then add them together. I want to cross reference $hole1 and $hole2 to the arrays listed and if they were to return $twoarray and $fourarray the sum would be 6, the following code is an idea of what I want to accomplish but this code wont work.

How do I assign the same value to multiple checksums and then add the results of those together?

Is using an array the correct way of doing this?

$man =  PixelChecksum(263, 57, 263+6, 57+12)
$hole1 =   PixelChecksum(263, 227, 263+6, 227+12)
$hole2 =   PixelChecksum(278, 227, 278+6, 227+12)

Dim $twoarray[4] = [3748832232, 2738339650, 1625400038, 1772667105]
Dim $threearray[4] = [2974719466, 1707260897, 1709416242, 3295460545]
Dim $fourarray[4] = [4078934460, 2519251135, 1635752540, 1124317625]
Dim $fivearray[4] = [1352832858, 3164059556, 3839399741, 2743842809]
Dim $sixarray[4] = [1240763093, 558476565, 358779529, 4115115871]

$twoarray[4] = 2
$threearray[4] = 3
$fourarray[4] = 4
$fivearray[4] = 5
$sixarray[4] = 6
Select

    Case $man = $twoarray[4]
if $hole1 + $hole2 == 6
then MouseClick("left", 278, 411)
EndSelect

Share this post


Link to post
Share on other sites



Will someone please help me correct my code. Or point me in the right direction.

Share this post


Link to post
Share on other sites

I looke at this twice now... once early this morning, and now.

1. I don't see the array.

2. You have specifically [4] defined with 4 pixelchecksums

3. Then you override the values of the same ones you just defined with 2,3,4,5,6.

Is this all the code?

Are you trying to do something like:

While 1
$hole1 =   PixelChecksum(263, 227, 263+6, 227+12)
$hole2 =   PixelChecksum(278, 227, 278+6, 227+12)

Dim $twoarray[5]
$twoarray[1] = 3748832232; gives the first value of the array
$twoarray[2] = 2738339650; second value
$twoarray[3] = 1625400038; third
$twoarray[4] = 1772667105; fourth

For $i = 1 To $twoarray[0]
    If $hole1 + $hole2 = $twoarray[$i] Then
        MouseClick("left", 278, 411)
    EndIf
Next
Sleep(10)
For $x = 1 To etc...
Next
Wend
; then you could do a "For/Next Loop" for each of the arrays you are trying to set up.

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

ronsrules,

Thanks for replying, and the example of code. I am very new to arrays and really don't know how to code them, or even if that is what I should be using in this code. The first half of what you did is what I am looking for, but I don't want to add the two checksums together. I want to have the four checksums return true for a variable, which that variable is assigned a number.

Hopefully I can explain it better

There are two spots in a window which can have multiple checksum results, 4 of which i want to return the same result.

For example I think this array says that it will return true if any of the following checksums

Dim $twoarray[5]
$twoarray[1] = 3748832232; gives the first value of the array
$twoarray[2] = 2738339650; second value
$twoarray[3] = 1625400038; third
$twoarray[4] = 1772667105; fourth

I am not really familiar with arrays, and not sure if they can work as a logical or, but in ansi c++ it would be something like

$man =  PixelChecksum(263, 57, 263+6, 57+12)

int $hole1(void)
{

    int nValue = 0;

    if (PixelChecksum(263, 227, 263+6, 227+12) == (3748832232 || 2738339650 || 1625400038 || 1772667105))
        nValue = 2;

    if (PixelChecksum(263, 227, 263+6, 227+12) == (2974719466 || 1707260897 || 1709416242 || 3295460545))
        nValue = 3;

    if (PixelChecksum(263, 227, 263+6, 227+12) == (4078934460 || 2519251135 || 1635752540 || 1124317625))
        nValue = 4;

    if (PixelChecksum(263, 227, 263+6, 227+12) == (1352832858 || 3164059556 || 3839399741 || 2743842809)
        nValue = 5;


    return(nValue);
}

if {
($man == (3748832232 || 2738339650 || 1625400038 || 1772667105)) && ($hole1 + $hole2 == 8)
then MouseClick("left", 278, 411)

Sorry about the mixing of code, this was the best way I could explain it. I hope this makes sense.

Share this post


Link to post
Share on other sites

You can add the others... Sounds like you just want an "Or" statement.

Func CHECK_VALUE($nValue)
Local $CHECK_ONE = PixelChecksum(263, 227, 263+6, 227+12)

If $CHECK_ONE == 3748832232 Or $CHECK_ONE == 2738339650 Or $CHECK_ONE == 1625400038 Or $CHECK_ONE == 1772667105 Then $nValue = 2

Return $nValue
EndFunc

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Thank you so much that is what I needed. Two quick questions:

To reference it later I just use $nValue == 4

Right?

So to do the others I would do the following

Func CHECK_VALUE($nValueman)
Local $CHECK_MAN = PixelChecksum(263, 227, 263+6, 227+12)

If $CHECK_MAN == 3748832232 Or $CHECK_MAN == 2738339650 Or $CHECK_MAN == 1625400038 Or $CHECK_MAN == 1772667105 Then $nValueman = 2

Return $nValueman
EndFunc

Func CHECK_VALUE($nValue1)
Local $CHECK_ONE = PixelChecksum(263, 227, 263+6, 227+12)

If $CHECK_ONE == 3748832232 Or $CHECK_ONE == 2738339650 Or $CHECK_ONE == 1625400038 Or $CHECK_ONE == 1772667105 Then $nValue = 2

Return $nValue1
EndFunc


Func CHECK_VALUE($nValue2)
Local $CHECK_TWO = PixelChecksum(263, 227, 263+6, 227+12)

If $CHECK_TWO == 3748832232 Or $CHECK_TWO == 2738339650 Or $CHECK_TWO == 1625400038 Or $CHECK_TWO == 1772667105 Then $nValue2 = 2
Else $nValue2 = 0
Return $nValue2
EndFunc

ETC....

And my other question is I can then change the $nValues based on what they add up to

If $nValue1 == 11 AND $nValue1 + $nValue2 + $nValue3 > 21 Then $nValue1 = 1
If $nValue2 == 11 AND $nValue1 + $nValue2 + $nValue3 > 21 Then $nValue2 = 1
If $nValue3 == 11 AND $nValue1 + $nValue2 + $nValue3 > 21 Then $nValue3 = 1
If $nValue4 == 11 AND $nValue1 + $nValue2 + $nValue3 > 21 Then $nValue4 = 1
If $nValue5 == 11 AND $nValue1 + $nValue2 + $nValue3 > 21 Then $nValue5 = 1

Select

    Case $nValueman == 2
    If $nValue1 + $nValue2 + $nValue3  < 11 AND $nValue1 Or $nValue2 != 11
        MouseClick("left", 278, 411)
    If $nValue1 + $nValue2 + $nValue3  == 11 AND $nValue1 Or $nValue2 != 11
        MouseClick("left", 218, 390)
    If 12 <= $nValue1 + $nValue2 + $nValue3  <= 14 AND $nValue1 Or $nValue2 != 11
        MouseClick("left", 278, 411)
EndSelect

Does this look correct?

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  
Followers 0