Dieuz Posted October 4, 2007 Share Posted October 4, 2007 (edited) Hi, I am looking for a way to find A specific pixel on the screen. The problem is that I cannot search for a color because this color appear multiple time on the screen. The way I am trying to make this work is to specify every color pixel around the one I am looking for. Here's the picture (x8 zoom) of the pixel I am searching for ( the red one ):Hex Colors of every pixel around the one I am searching for:0x525372 ------ 0xBABBCD ------ 0x707098 0x525372 ------ [0xFF0000] ------ 0xBABBCD 0x525372 ------ 0x525372 ------ 0x525372Pixel 1 ------ Pixel 2 ------ Pixel 3 Pixel 4 ------ [THE PIXEL] ------ Pixel 5 Pixel 6 ------ Pixel 7 ------ Pixel 8Can anyone point me on how can I search for the coordinate(x,y) of the red pixel knowing the colors of each pixels around it. Edited October 4, 2007 by Dieuz Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted October 4, 2007 Moderators Share Posted October 4, 2007 Hi, I am looking for a way to find A specific pixel on the screen. The problem is that I cannot search for a color because this color appear multiple time on the screen. The way I am trying to make this work is to specify every color pixel around the one I am looking for. Here's the picture (x8 zoom) of the pixel I am searching for ( the red one ): Hex Colors of every pixel around the one I am searching for: 0x525372 ------ 0xBABBCD ------ 0x707098 0x525372 ------ [0xFF0000] ------ 0xBABBCD 0x525372 ------ 0x525372 ------ 0x525372Cool... Whatcha got so far? BTW, I did make something with PixelSearch I believe that finds all the pixels of that color instead of stopping at the first one found... http://www.autoitscript.com/forum/index.ph...st&p=266683 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. Link to comment Share on other sites More sharing options...
Valuater Posted October 4, 2007 Share Posted October 4, 2007 (edited) If PixelGetColor( Pixel 1, y ) = 0x525372 And PixelGetColor( Pixel 2, y) = 0xBABBCD And ..etc 8) EDIT: that does look like a winner RON!!! Edited October 4, 2007 by Valuater Link to comment Share on other sites More sharing options...
Dieuz Posted October 4, 2007 Author Share Posted October 4, 2007 (edited) If PixelGetColor( Pixel 1, y ) = 0x525372 And PixelGetColor( Pixel 2, y) = 0xBABBCD And ..etc 8) The problem is that I dont have any coordinates. The red pixel will act as a pointer. Every others actions in my script will depend of the red pixel coordinates. I cannot use PixelGetColor because I dont have any coordinates... I want to find this red pixel anywhere on the screen. I will work on something and let you know what I got. I am a little bit affraid of the time that it could take to search all the screen... Edited October 4, 2007 by Dieuz Link to comment Share on other sites More sharing options...
galpha Posted October 4, 2007 Share Posted October 4, 2007 Please check to make sure you do need all the 8 pixels around. It's possible to do, but would be very slow. Check to see if you can make it check only a fewer pixels around (like only the top 3 ones for e.g.). If you got no other choices, then I'll write in function of it. Make sure that's what you want! Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted October 4, 2007 Moderators Share Posted October 4, 2007 Guys... Use the function I provided to find the Red pixel... then do a search for the 8 Pixels confirming it's what you want... It's as fast as you are going to get with native autoit. 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. Link to comment Share on other sites More sharing options...
Paulie Posted October 4, 2007 Share Posted October 4, 2007 (edited) its not very fast.. and i have no way to test it... but logic says it should work. O'course , credz go to Smoke for the _PixelSearchEx() expandcollapse popup#include <Array.au3> $array = _PixelSearchEx(0, 30, 1000, 1000, 0xFF0000);Finds all red Dim $Results[1][2],$count = 0 For $i = 1 to Ubound($array,1)-1 If PixelGetColor($array[$i][0]-1,$array[$i][0]-1) = 0x525372 and _ PixelGetColor($array[$i][0]-1,$array[$i][0]) = 0x525372 and _ PixelGetColor($array[$i][0]-1,$array[$i][0]+1) = 0x525372 and _ PixelGetColor($array[$i][0],$array[$i][0]-1) = 0xBABBCD and _ PixelGetColor($array[$i][0],$array[$i][0]+1) = 0x525375 and _ PixelGetColor($array[$i][0]+1,$array[$i][0]-1) = 0x707098 and _ PixelGetColor($array[$i][0]+1,$array[$i][0]) = 0xBABBCD and _ PixelGetColor($array[$i][0]+1,$array[$i][0]+1) = 0x525372 Then $Count+=1 ReDim $Results[$Count][2] $Results[$Count][0] = $array[$i][0] $Results[$Count][1] = $array[$i][1] EndIf Next _ArrayDisplay($Results) Func _PixelSearchEx($xTop, $yTop, $xBottom, $yBottom, $nColor, $iShade = 0, $iStep = 1) Local $aPix, $aCoords, $nYAdd, $iAdd For $xCC = $xTop To $xBottom $nYAdd = 0 While $nYAdd <= $yBottom $aPix = PixelSearch($xCC, $yTop + $nYAdd, $xCC, $yBottom, $nColor, $iShade, $iStep) If Not IsArray($aPix) Then ExitLoop If Not IsArray($aCoords) Then Local $aCoords[1][2] $nYAdd += ($aPix[1] - $yTop) + 1 $iAdd += 1 ReDim $aCoords[$iAdd + 1][2] $aCoords[$iAdd][0] = $aPix[0] $aCoords[$iAdd][1] = $aPix[1] WEnd Next If IsArray($aCoords) Then Return $aCoords Return SetError(1, 0, 0) EndFunc Edited October 4, 2007 by Paulie Link to comment Share on other sites More sharing options...
galpha Posted October 4, 2007 Share Posted October 4, 2007 (edited) Guys... Use the function I provided to find the Red pixel... then do a search for the 8 Pixels confirming it's what you want... It's as fast as you are going to get with native autoit. Yea use this function, except it would be built like this: Pixel 1 ------ Pixel 2 ------ Pixel 3 Pixel 4 ------ [THE PIXEL] ------ Pixel 5 Pixel 6 ------ Pixel 7 ------ Pixel 8 Pixel 1-4-6-7-8 = $array1 (since they all have the same color: dark grey) Pixel 2-5 = $array2 (same color: light grey) Pixel 3 = $array3 THE PIXEL = $array4 (red dot) EDIT:: Looks like Paulie wrote a simplier way, should have tought about it Edited October 4, 2007 by galpha Link to comment Share on other sites More sharing options...
Airwolf Posted October 4, 2007 Share Posted October 4, 2007 You could try using checksums...http://www.autoitscript.com/forum/index.ph...mp;#entry363111 Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt Link to comment Share on other sites More sharing options...
Dieuz Posted October 4, 2007 Author Share Posted October 4, 2007 (edited) Thanks Paulie! Here's an actual picture to test it... Let's see if it works.EDIT: Doesnt work for me, let me know if it works for you? Error Here PixelGetColor($array[$i][0],$array[$i][0]+1) = 0x525375 and _Change 0x525375 to 0x525372Doesnt seem to correct the problem... Edited October 4, 2007 by Dieuz Link to comment Share on other sites More sharing options...
Paulie Posted October 4, 2007 Share Posted October 4, 2007 (edited) That image is too big... the red spot int the center is about 7x7 pixels... at least on my resolution (2560x1024) NVM you edited the image... testing... Edited October 4, 2007 by Paulie Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted October 4, 2007 Moderators Share Posted October 4, 2007 (edited) If you follow this whole thread, and look at the code that I'm giving you the link too... you'd probably find this to be the making of a solution... and much faster: http://www.autoitscript.com/forum/index.ph...st&p=300569So you could tear apart that code to do a PixelSearch like it is doing, then once the color is found to do a PixelCheckSum of the area needed if matched then you found your coords. Edited October 4, 2007 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. Link to comment Share on other sites More sharing options...
Dieuz Posted October 5, 2007 Author Share Posted October 5, 2007 (edited) I will need to get the value of the checksum before entering it into my script, right? so I could compare the same value every time. EDIT: Just thought of something, could it compare a certain region (around the pixel) with an image(.gif) then try to find the one that fit exactly. Edited October 5, 2007 by Dieuz Link to comment Share on other sites More sharing options...
Dieuz Posted October 5, 2007 Author Share Posted October 5, 2007 (edited) This seem to work for me:expandcollapse popup#include <Array.au3> Global $x, $y $Found = 0 sleep(5000) $array = _PixelSearchEx(0, 0, 1000, 1000, 0xFF00000);Finds all red For $i = 1 to Ubound($array,1)-1 If PixelGetColor($array[$i][0]-1,$array[$i][1]-1) = 0x525372 and _ PixelGetColor($array[$i][0]-1,$array[$i][1]) = 0x525372 and _ PixelGetColor($array[$i][0]-1,$array[$i][1]+1) = 0x525372 and _ PixelGetColor($array[$i][0],$array[$i][1]-1) = 0xBABBCD and _ PixelGetColor($array[$i][0],$array[$i][1]+1) = 0x525372 and _ PixelGetColor($array[$i][0]+1,$array[$i][1]-1) = 0x707098 and _ PixelGetColor($array[$i][0]+1,$array[$i][1]) = 0xBABBCD and _ PixelGetColor($array[$i][0]+1,$array[$i][1]+1) = 0x525372 Then MsgBox(0,"","found!" & @CRLF & $array[$i][0] & ", " & $array[$i][1]) $Found = 1 Else EndIf Next If $Found = 1 Then Else MsgBox(0,"Crap", "Pixel not found") EndIF Func _PixelSearchEx($xTop, $yTop, $xBottom, $yBottom, $nColor, $iShade = 0, $iStep = 1) Local $aPix, $aCoords, $nYAdd, $iAdd For $xCC = $xTop To $xBottom $nYAdd = 0 While $nYAdd <= $yBottom $aPix = PixelSearch($xCC, $yTop + $nYAdd, $xCC, $yBottom, $nColor, $iShade, $iStep) If Not IsArray($aPix) Then ExitLoop If Not IsArray($aCoords) Then Local $aCoords[1][2] $nYAdd += ($aPix[1] - $yTop) + 1 $iAdd += 1 ReDim $aCoords[$iAdd + 1][2] $aCoords[$iAdd][0] = $aPix[0] $aCoords[$iAdd][1] = $aPix[1] WEnd Next If IsArray($aCoords) Then Return $aCoords Return SetError(1, 0, 0) EndFuncThx to Paulie for the help!Can anyone test it too with this picture:Paulie: I had to replace $array[$i][0] by $array[$i][1] for the y coordinate. Edited October 5, 2007 by Dieuz Link to comment Share on other sites More sharing options...
Matrix112 Posted October 5, 2007 Share Posted October 5, 2007 maybe this is a good idea. generating a checksum with a line of pixels it´s not ready now, just a though about it this should find a section out of many pixels i hope $test = _PixelChecksumFindLine ("3120470613");<--- checksum out of a ine of some pixels If $test = -1 Then MsgBox(0, "Test", "was found") Else MsgBox(0, "Test", "not found " & $test) EndIf Exit Func _PixelChecksumFindLine($chksm) $x = @DesktopWidth $y = @DesktopHeight For $a = 1 To $y $sum = PixelChecksum(0,$a,$x,$a) If $sum = $chksm Then Return $a ExitLoop EndIf Next Return -1 EndFunc 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