rony2006 Posted April 19, 2016 Posted April 19, 2016 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]]] )
BrewManNH Posted April 19, 2016 Posted April 19, 2016 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 GudeHow 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
rony2006 Posted April 19, 2016 Author Posted April 19, 2016 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?
Bert Posted April 20, 2016 Posted April 20, 2016 I'm going to ask - is there some reason you can't hook into the control? Pixel searching should be used ONLY if there is no other option and even then it should be avoided The Vollatran project My blog: http://www.vollysinterestingshit.com/
rony2006 Posted April 20, 2016 Author Posted April 20, 2016 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.
Bert Posted April 20, 2016 Posted April 20, 2016 Pixel search is inherently unreliable. The reasons are many - the window may move, window may not have focus, a popup may happen, just to name a few. What have you tried to hook into the control? The Vollatran project My blog: http://www.vollysinterestingshit.com/
tonycst Posted May 17, 2018 Posted May 17, 2018 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.
Somerset Posted May 17, 2018 Posted May 17, 2018 3 hours ago, tonycst said: (sorry to wake up the topic but i thought ill contribute) Topic is 2 years old. Necro-poster.
Earthshine Posted May 17, 2018 Posted May 17, 2018 Indeed My resources are limited. You must ask the right questions
tonycst Posted May 17, 2018 Posted May 17, 2018 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.
jdelaney Posted May 17, 2018 Posted May 17, 2018 https://www.autoitscript.com/wiki/Forum_FAQ IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Developers Jos Posted May 17, 2018 Developers Posted May 17, 2018 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.
Moderators Melba23 Posted May 17, 2018 Moderators Posted May 17, 2018 (edited) 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 May 17, 2018 by Melba23 Wrong button too soon 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Recommended Posts