Sign in to follow this  
Followers 0
£åߥ®Ñth

I have a question please.

4 posts in this topic

Well, here is what i want to do, and im by far no pro using autoit.

But i do like the language allot, and i have been successful with other projects using it.

I looked around a little and did not see/notice anything that helps me so i made a post.

I want to do a checksum of an area and then when a change is detected, i want to click where the change was found.

I tried doing it like this, but i get a "Subscript used with non-Array variable."

So is there a way to do a click on a detected change when using PixelChecksum?

Thank you for any help i may get.

While $look = 1
    $coord = PixelChecksum(59, 100, 757, 525)
    If Not @error Then
        MouseClick("left", $coord[0], $coord[1], 1, 1)
        Sleep(9000)
    EndIf
WEnd

Share this post


Link to post
Share on other sites



The problem here is that PixelChecksum doesn't work the way you are wanting it.

Notice in the remarks in the documentation: A checksum only allows you to see if "something" has changed in a region - it does not tell you exactly what has changed.

For example, see this?

$checksum = PixelChecksum(0,0, 50,50)
MsgBox(0, 'Checksum', $checksum)

On my system (at this moment) that gives me: 2481650658

And it will continue to give me that number, as long as nothing changes in the top left corner of my screen.

Now I moved a window there and I get this: 2687839869

See the difference? Unfortunately, there's no calculation that tells you just what the difference means - all you know is that it is different.

So unfortunately, I really don't know how you could go about doing what you want in your actual script, but this might get you started:

$firstChecksum = PixelChecksum(59, 100, 757, 525) ; First we grab the checksum of the area, we will use this as a base to start from

While $look = 1
    $newChecksum = PixelChecksum(59, 100, 757, 525)
    If $firstChecksum <> $newChecksum Then
        MsgBox(0, 'Checksum', 'SOMETHING changed! But we don''t know what, sorry :(')
        ExitLoop
    EndIf
WEnd

Share this post


Link to post
Share on other sites

Yes i get that as well, So your saying there is no way to get a coord on a check sum :) .

Maybe this can be implemented in a future update of autoit or something.

Unless someone else has or knows some work around, i would like to see it.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Maybe this can be implemented in a future update of autoit or something.

Not very likely. Which coord should it return anyway? What if 5 pixels change? There's no real easy way to do it, but here's the best method I can think of (for you to code it yourself, which will be your best [probably only] choice), and there are problems with this too which I'll go over after.

1) Check through every pixel in your chosen area (PixelGetColor) and store the colours in an array (this will add up quickly, in a 100x100 pixel square, you're looking at 10,000 array entries).

2) Get the checksum of the area.

3) As exampled in my script above, loop the checksum until a difference is found.

4) When the difference is found, start looping through the array comparing the colours, when you hit one that is different, return that position.

Here's some pseudo code:

$firstChecksum = PixelChecksum(0, 0, 100, 100)
Local $storeColour[101][101]
For $X = 0 to 100
    For $Y = 0 to 100
        $storeColour[$X][$Y] = PixelGetColor($X, $Y)
    Next
Next
While 1
    $newChecksum = PixelChecksum(0, 0, 100, 100)
    If $firstChecksum <> $newChecksum Then
        For $X = 0 to 100
            For $Y = 0 to 100
                If PixelGetColor($X, $Y) <> $storeColour[$X][$Y] Then
                    MsgBox(0, 'Different', 'Changed pixel at ' & $X & ' x ' & $Y)
                    ExitLoop 3
            Next
        Next
        MsgBox(16, 'Error', 'Could not find changed pixel!')
        ExitLoop
    EndIf
WEnd

The problem with this is that it's so terribly slow to check every pixel, that the checksum itself could be different from the time you first take it, to the time you finish checking all the pixels. And that's just ONE of the slowness issues.

PS: Just so we don't get into that argument, I'm pretty sure it wouldn't be that much faster even if it were built-in.

Edited by Saunders

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