Jump to content
Sign in to follow this  

Save 2 pixel locations (getpixelcolor) as a value

Recommended Posts


I'm working on a really simple bejeweled type bot (clone game). I've read the older post here on the same topic and I figured out how to make the bot, but I'm still learning this language. I have a slightly buggy but working script going.

I was using 1 pixel location to identify gem type by color. But the problem is many gems will have a similar shade and give false positives. So I want to grab two pixel locations on the same gem to identify it, and maybe use the result as an integer?(hex?).

So something like this:

$gem1 = PixelGetColor(x1,y1) + PixelGetColor(x2,y2)

$gem2 = PixelGetColor(x1,y1) + PixelGetColor(x2,y2)

$gem3 = PixelGetColor(x1,y1) + PixelGetColor(x2,y2)

$gem4 = PixelGetColor(x1,y1) + PixelGetColor(x2,y2)

If $gem1 = $gem2 AND $gem4 Then;gem matchs gems on each side

MouseClickDrag ( "left", x, y, x, y ) ;Moves gem 4 to gems 3 position


What is the proper way to combine two pixel locations with autoits language? ---> $gem1 = PixelGetColor(x1,y1) + PixelGetColor(x2,y2)

Edited by Eliflint

Share this post

Link to post
Share on other sites

I have a better solution for you. Use the PixelCheckSum function. Compare existing checksums to the ones that your code is returning to determine what gem you are looking at.

I've recently been botting for Minesweeper ( yeah, I know rite ). This should give you a basic idea how to use PixelChecksum. This reads what the mine is at x, y location.

Func _WinMine_ReadMine($x, $y)
    If Not _WinMine_IsInBound($x, $y) Then Return $MINE_QUESTION
    $lMinePos = _WinMine_GridToPixel($x, $y)
    $lMineChecksum = PixelChecksum($lMinePos[0], $lMinePos[1], $lMinePos[0]+10, $lMinePos[1]+10, 1, $hWnd)
    Switch $lMineChecksum
        Case 39198862 ; Unknown
            Return $MINE_UNKNOWN
        Case 1084229648 ; Empty
            Return $MINE_EMPTY
        Case 2517165927 ; Number 1
            Return $MINE_ONE
        Case 1440528705 ; Number 2
            Return $MINE_TWO
        Case 326160918 ; Number 3
            Return $MINE_THREE
        Case 1564389505
            Return $MINE_FOUR
        Case 437628609
            Return $MINE_FIVE
        Case 572048513
            Return $MINE_SIX
        Case 2443509166 ; Flag
            Return $MINE_FLAG
        Case 258470783 ; Question mark
            Return $MINE_QUESTION
        Case 1965262389, 2770815814
            Return $MINE_BOMB
        Case Else
            ConsoleWrite("! Unknown mine detected (Mine number 7 still undetected):" & $lMineChecksum & @CRLF )
            Return SetError(1,0,-10)

Source: http://www.autoitscript.com/forum/index.php?showtopic=84231

Edited by Manadar

Share this post

Link to post
Share on other sites

Much appreciated. This requires me to learn the language a little more so I guess I'll start reading up, and studying your code.

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.