Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

more thorough pixelsearch


  • Please log in to reply
No replies to this topic
kingtim
  • Members
  • 5 posts
  • Last active: Jul 13 2010 10:29 AM
  • Joined: 08 Jun 2010
i've been using ahk for a while but never joined this forum so i finally did and thought it would be nice to share this with you :)

this function is the same as pixelsearch but instead of one pixel it searches for 3 pixels in a row. here is the code:




pixelfind(ByRef pixelfoundx,ByRef pixelfoundy,x1,y1,x2,y2,ColorID1,ColorID2,ColorID3)
{
beginx:=x1
beginy:=y1
eindx:=x2
eindy:=y2
teller=1
end=1

loop
{
pixelsearch,pixelx%teller%,pixely%teller%,x1,y1,x2,y2,ColorID1,,fast
if errorlevel=0
{
pixelgetcolor,pixel2,pixelx%teller%+1,pixely%teller%
if pixel2=%ColorID2%
{
pixelgetcolor,pixel3,pixelx%teller%+2,pixely%teller%
if pixel3=%ColorID3%
{
pixelfoundx:=pixelx%teller%
pixelfoundy:=pixely%teller%
break
}
}
x1:=pixelx%teller%+1
y1:=pixely%teller%
y2:=pixely%teller%
teller:=teller+1
end=0
}
if errorlevel=1
{
if end=1
{
pixelfoundx:=
break
}
end=1
x1:=beginx
tellermin1:=teller-1
y1:=pixely%tellermin1%+1
y2:=eindy
}
}
}

it can be used exactly the same way as pixelsearch exept you give 3 colourid's (it's easy as that :) )


it can be used when a normal pixelsearch doesn't suffice but when imagesearch is too slow or when you don't want to constantly include images with your script.

sorry i didn't include any explanation of the code but if you don't understand any of it just ask :)

i'd like to hear your comments and tips to improve it.[/code]