Sign in to follow this  
Followers 0
rony2006

Pixel Search problem or bug

6 posts in this topic

Hello,

I think pixelsearch has a bug or something because I have a problem that is killing my mind.

So I use the following code 

$x = 1500
$y = 1000
$iColor1 = PixelGetColor($xp, $yp)
&hex = Hex ($iColor1, 6)


$aCoord = PixelSearch($x,$y, 2,2 ,$hex, 10)
If Not @error Then
    MsgBox($MB_SYSTEMMODAL, "", "X and Y are: " & $aCoord[0] & "," & $aCoord[1])
EndIf

I get all the time the message that x and y are something like 200, 300.

Why is this happening? Can be because 

color Color value of pixel to find (in decimal or hex).

should have 0x at the 

PixelSearch ( left, top, right, bottom, color [, shade-variation = 0 [, step = 1 [, hwnd]]] )

Share this post


Link to post
Share on other sites



This code won't even run as written here. &hex needs to be $hex.

By the way, you don't need to convert the color to hex, just use the decimal number you get back from PixelGetColor.

Where are the variables $xp and $yp coming from?


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

there was a mistake with the  &hex needs to be $hex.  when i made the code for the topic. Not this is the problem

 

$x is made by something like $originex - 100

y is made by something like $originey + 25

$originex and $originey are big numbers, more then 1000,

 

The ideea is that I want to check if 2 areas if they are the same color (the problem is that there are some little variance on color)

 

Each area can have 4 color (red, green, black and blue). There can be some case were both area are the same (red red, black black), Even if the areas are the same there is a little diference in color so I cannot use decimal code and check if they match or not.

 

I tried to use decimal code with some tolerance when checking but not working because the difference between black and blue for ex is not the same as the diff between red and green. (i mean the value, the number).

 

How I can do this?

Share this post


Link to post
Share on other sites

No, I cannot hook in the control.

 

And why you say I should avoid Pixel Search? I want to use it only for searching in a small square 2x2 or something like that.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0