M3m Posted July 1, 2009 Posted July 1, 2009 I'm coding a bot for some stupid game my friend keeps beating me at. I basically want to perform a pixelsearch in an area that's mostly one colour - a background - until the pixelsearch encounters a pixel that is not part of the background. Instinctivly, I typed : pixelsearch(left, top, right, bottom, NOT 0x000000) But, of course, it's not working (otherwise, I'd be beating my friend right now) What's the easiest way to do it ? Here's the whole messy, uncleaned raw code I just finished : expandcollapse popupOpt("MouseCoordMode",0) Opt("MustDeclareVars",1) Global Const $gauche = 264 Global Const $haut = 320 Global Const $droite = 593 Global Const $bas = 539 Global $CooBalle[2] Func GetCoord() Local $CooTemp[2] = [0,0] While ($CooTemp[0] = 0 AND $CooTemp[1] = 0) $CooTemp = pixelsearch($gauche,$haut,$droite,$bas, NOT 0x000000) WEnd While ((PixelGetColor($CooTemp[0]+5, $CooTemp[1])= 0) AND (PixelGetColor($CooTemp[0], $CooTemp[1]+5)= 0)) OR $CooTemp[0] < $droite Local Const $incr = 1 $CooTemp = pixelsearch($CooTemp[0]+$incr, $CooTemp[1], $droite, $CooTemp[1], NOT 0) WEnd Local $check = 0 While $check = 0 If ((PixelGetColor($CooTemp[0]+5, $CooTemp[1])= NOT 0) AND (PixelGetColor($CooTemp[0], $CooTemp[1]+5)= NOT 0)) Then $check = 1 EndIf While ((PixelGetColor($CooTemp[0]+5, $CooTemp[1])= 0) AND (PixelGetColor($CooTemp[0], $CooTemp[1]+5)= 0)) $CooTemp = pixelsearch($gauche, $CooTemp[1]+1, $droite, $bas, NOT 0) WEnd While ((PixelGetColor($CooTemp[0]+5, $CooTemp[1])= 0) AND (PixelGetColor($CooTemp[0], $CooTemp[1]+5)= 0)) OR $CooTemp[0] < $droite Local Const $incr = 1 $CooTemp = pixelsearch($CooTemp[0]+$incr, $CooTemp[1], $droite, $CooTemp[1], NOT 0) WEnd WEnd $CooBalle = $CooTemp EndFunc While 1 GetCoord() Mousemove($CooBalle[0],$CooBalle[1],0) WEnd (Yes it's particularly terrible, quick little coding here.)
GodlessSinner Posted July 1, 2009 Posted July 1, 2009 (edited) ;X1----------Y1 ; | \ | ; | \ | ; | \ | ;Y2----------X2 ; ;Time taken = ((X2-x1)*(Y2-Y1))*$sleep/60 = time in minutes. ;======================================== $y2 = "200" $x2 = "200" $sleep = 1000 For $y1 = 100 To $y2 For $x1 = 100 To $x2 If Hex(PixelGetColor( $x1 , $y1)) <> "0x000000" Then MouseClick("Left",$x1,$y1,1,0) Sleep($sleep) EndIf Next Next Edited July 1, 2009 by Vitas _____________________________________________________________________________
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now