DrCheeto Posted December 1, 2010 Share Posted December 1, 2010 Hi as you should know the pixelgetcolor functions requires and x1/y1 and a x2/y2 which forms a box. This issue I am having is I want to find the position of multiple objects with the same color, but can not because it only retrieves the first pixel it finds, and starting at the position it found the last pixel doesn't work because it forms a box example.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxYxxxxxxxxxxxxxxxxxxxxxxxxxxYxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxSay this is a bunch of pixels, after it found the first Y and if I started searching from that point, it would never find the other Y because now it has cut off every thing above and to the left of the first Y.So I am not sure what I can do, but there has to be some support, I cant be the first person who wanted to find multiple objects with this.The only other option i can think of is kinda grueling, where I literally make an x,y map and have a loop with the box only having a y of like 4.Any help would be greatly appreciated. Link to comment Share on other sites More sharing options...
iamtheky Posted December 1, 2010 Share Posted December 1, 2010 I use this to grab all the red in an image, you can certainly modify it to find whatever color you are looking for. Also in its current form it expects the capture area to be a perfect square. expandcollapse popup#include <Array.au3> Global $SAVEFILE = "c:\test\loading2.txt" Global $IMAGE = "REDloading.bmp" Dim $RED Dim $ALL[1] Dim $Columns[1] $loading = _PicToArray($IMAGE, 400) _findcolor ($loading, "FF0000") _save($ALL , $SAVEFILE) Func _findcolor ($SrcArray, $Color) For $i = 0 TO Ubound ($SrcArray) - 1 $RED = _ArrayFindAll ($SrcArray , $Color , 0 , 0 ,0 ,1, $i) For $k = 0 to ubound ($RED) - 1 _ArrayAdd ($Columns , $i) Next _ArrayConcatenate ($ALL , $RED) Next EndFUnc Func _PicToArray($pic, $size) Dim $BArray[$size][$size] SplashImageOn("", $pic , $size, $size, 0, 0, 1) For $B = 0 To ubound ($BArray, 1) - 1 For $C = 0 To ubound ($BArray, 2) - 1 $BArray[$B][$C] = "0x" & Hex(PixelGetColor($B + 1, $C + 1), 6) Next Next splashoff () Return $BArray EndFunc Func _save($SrcArray , $FileName) $pixFile = fileopen ($FileName , 2) For $i = 1 to ubound ($All) - 1 filewriteline ($pixFile , $Columns[$i]) filewriteline ($pixFile , $ALL[$i]) Next FileClose ($pixFile) EndFunc ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
DrCheeto Posted December 1, 2010 Author Share Posted December 1, 2010 Aight well I am looking for all of the color in an image, its not a file, its getting the pixels from a game screen. Link to comment Share on other sites More sharing options...
PsaltyDS Posted December 1, 2010 Share Posted December 1, 2010 ...its not a file, its getting the pixels from a game screen.Sigh, just had to use the G-word. Read this sticky post. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
DrCheeto Posted December 1, 2010 Author Share Posted December 1, 2010 (edited) Let me correct myself; Aight well I am looking for all of the color in an image, its not a file I can download, its getting the pixels from a website image, this image can change so there is no way to download it. And here is what I have come up with so far, but it will do the first like 30 rows in a split second, then after that takes like 40+ sec per row and I am not sure why. for $ncount = 751 to 978 step 2 $tmp = 22 $dr = 0 while ($dr <> 1) if $tmp > 300 then $dr = 1 endif $Coords = PixelSearch($tmp, $ncount, 259, $ncount, 0x7EBFF1) if isarray($coords) = true then $cods = PixelSearch($coords[0]+3, $ncount, $coords[0]+3, $ncount, 0x7EBFF1) if isarray($cods) Then $tmp = $coords[0]+20 $arct += 2 $places[$arct -2] = $coords[0] $places[$arct -1] = $coords[1] mousemove($coords[0],$coords[1]) sleep(300) endif Else $dr = 1 endif wend if mod(($ncount-1),10) = 0 Then MsgBox(0,"lol",$nCount) endif next Edited December 1, 2010 by DrCheeto Link to comment Share on other sites More sharing options...
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