Jump to content

Pixel Search problem or bug


Recommended Posts

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]]] )

Link to comment
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

Link to comment
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?

Link to comment
Share on other sites

  • 2 years later...

I cant live without pixel search (sorry to wake up the topic but i thought ill contribute)
I combat those problems with manipulating windows of interest.

Obviously it wont find needed color on a window that has part of the window with that color outside of the screen area. It cant see what you cant see. Operating system simply not rendering it to you so there is nothing to look at if needed color is outside of the monitor resolution area.

I always do WinActivate() before i search what ever color i need in a given window. I also always use Opt("PixelCoordMode", 1) ; to search based on screen coordinates rather then the window of interest. This is because Window may not only move, but it can get resized as well, effectively FORCING you into adding more code to get that window position and size WinGetPos() ;returns [0] [1] [2] and [3] (see help file)

This is how i search for a needed color in an area of the screen (entire screen in this example)

$WindowHandle = WinGetHandle ($WindowToSearch)
$WinPos = WinGetPos ($WindowHandle)
$SearchLimitX = @DesktopWidth ;1920
$SearchLimitY = @DesktopHeight ;1080
WinActivate($WindowToSearch)
$Search = PixelSearch($WinPos[0],$WinPos[1],$SearchLimitX,$SearchLimitY, $PixelColor, 2, 1,$WindowHandle) ;2 for shade variation

In a loop situation, you can simply check if window is activated or not with just one line of code

If WinActive($WindowToSearch) = 0 Then WinActivate ($WindowToSearch)

 

Hope that helps.

Link to comment
Share on other sites

Allow me to ask you and everyone who reads these messages a question.

Before i come to this forum and post a question, i do google search.

If no answer is found, i come and post a new question, otherwise i click the link that has potential answer.

Link typically leads to posts that are old, but kept alive for years as more and more people began interested in the subject, and as years go by and autoit upgrades, scripts examples or UDF's in that topic become somewhat none functioning and needing an update to work with the current autoit release.

 

So i reply to one of those topics asking a question related to it, question that was already asked but not clarified and instead of an answer, i get something like this:

NECRO POSTER. THIS POST IS 8 YEARS OLD.

 

So my question is: Moderators are more interested in me creating more topics rather then posting in a relevant one instead ?
That will create so many topics talking about the same thing over and over again, making it very difficult to find the answer.
I am already struggling finding some answers because of how many topics exact same question had.

Another problem is that Moderators (Jos) doesnt like many same topics either. He would say "you just posted similar question" for which you either get  banned or a notice or your topic gets locked before you get your answer.
I've seen posting question on an old topic and that topic gets locked without giving the answer with just "this topic is so many years old, its necro so i lock it."
Then i think "thanks allot jerk I really needed the answer."

The way i see it working is like this: damn if you do, damn if you dont.
I cant question something thats old nor can i question something that has already been asked before. What the hell can i question then ?
Makes me logically confused.

Link to comment
Share on other sites

  • Developers
23 minutes ago, tonycst said:

Another problem is that Moderators (Jos) doesnt like many same topics either. He would say "you just posted similar question" for which you either get  banned or a notice or your topic gets locked before you get your answer.

mmm...   Not sure what you are looking for with this whole post but am not interested in a discussion.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Jos locked this topic
  • Moderators

tonycst,

The attitude you show in these forums is becoming rather tiresome - you do little but complain about practically everything, be it AutoIt or the Mod team. Please try and be a little less of an irritant.

Quote

So my question is: Moderators are more interested in me creating more topics rather then posting in a relevant one instead ?
That will create so many topics talking about the same thing over and over again, making it very difficult to find the answer.

I cant question something thats old nor can i question something that has already been asked before. What the hell can i question then ?

Because the language has changed so much over the years, old threads often are no longer really relevant because the functionality is now incorporated into the standard AutoIt installation or the code is so outdated that it will not run without considerable changes. So if you find that the only threads thrown up by a search are old - start a new one with a link to the old thread - that way the next searcher will find a more recent thread to start their own hunt.

M23


 

Edited by Melba23
Wrong button too soon

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...