supernewb Posted January 21, 2006 Posted January 21, 2006 I want to make a function with in a script that will scan a specific square area with in the screen and return a count of the amount of pixels in that area containing a specific color. I am very new to this and understand how to use the PixelSearch. But I don't understand how to loop it in order to acheive what I want. Thanks in advance, Newb
giantsquid Posted January 22, 2006 Posted January 22, 2006 Try something like for $x = $xstart to $xend for $y = $ystart to $yend if pixelgetcolor($x, $y) = $color then $count = $count + 1 next next where $xstart, $xend, $ystart, $yend are used to decide which rectangle of pixels to check, $color is the color you are looking for, and $count is used to record how many match. I did not test the code, but this is the general idea.
Moderators SmOke_N Posted January 22, 2006 Moderators Posted January 22, 2006 (edited) Try something like for $x = $xstart to $xend for $y = $ystart to $yend if pixelgetcolor($x, $y) = $color then $count = $count + 1 next next where $xstart, $xend, $ystart, $yend are used to decide which rectangle of pixels to check, $color is the color you are looking for, and $count is used to record how many match. I did not test the code, but this is the general idea. Nice Usage there Squid, should make that to a UDF for them !! Edit: Here you go, using your idea Dim $Window = 'Text of title of window to search' _PixelGetCount(0, 100, 0, 100, 0xFF0000, $Window) Func _PixelGetCount($xstart, $xend, $ystart, $yend, $c_Color, $w_Window = '') Local $count = '' For $x = $xstart to $xend For $y = $ystart to $yend If $w_Window <> '' Then If Not WinActive($w_Window) Then WinActivate($w_Window) EndIf If PixelGetColor($x, $y) = $c_Color Then $count = $count + 1 Next Next Return $count EndFunc Edited January 22, 2006 by SmOke_N 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.
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