CattBoy Posted August 29, 2017 Share Posted August 29, 2017 Hello! Can someone help me understand the basics input parameters for PixelSearch. Reading the help guide Parameters left left coordinate of rectangle. top top coordinate of rectangle. right right coordinate of rectangle. bottom bottom coordinate of rectangle. color Color value of pixel to find (in decimal or hex). shade-variation [optional] A number between 0 and 255 to indicate the allowed number of shades of variation of the red, green, and blue components of the color. Default is 0 (exact match). step [optional] Instead of searching each pixel use a value larger than 1 to skip pixels (for speed). E.g. A value of 2 will only check every other pixel. Default is 1. It is not recommended to use a step value greater than 1. hwnd [optional] Window handle to be used. Default is the desktop window If I want to search a rectangle inside the center of my desktop, using the WindowInfo tool from auto it, read the x and y mouse coordinates and use those as the values for the parameters? For this example lets say my screen resolution is 1920x1240. Drawing a search rectangle inside, for easy math will say it's 3/4th of the size of the full desktop. Now using the wininfo tool, I find the x and y of where I want the corner of the box to start. Mouse cords (480,930) and using the wininfo tool ill find the x,y of the opposite corner I want the box to end. (1440,310) The values of the pixelsearch function should be, (searching on red) Pixelseach Local $aCoord = PixelSearch(480, 930, 1440, 310, 0xFF0000) Is that correct? Link to comment Share on other sites More sharing options...
toto22 Posted August 29, 2017 Share Posted August 29, 2017 (edited) no, it's wrong. it should be like : Local $aCoord = PixelSearch(0, 0, 1, 1, 0xFF0000,0) so ur box is from point 1 (x1 = 0 , y1 = 0) to point 2 (x2=1 , y2=1) x1 should be < x2 and y1 < y2 in ur case i think it should be like : Local $aCoord = PixelSearch(480, 310, 1440, 930, 0xFF0000, 0) also u can add color variation t\at the end like: Local $aCoord = PixelSearch(0, 0, 1, 1, 0xFF0000, 10) (it will look for a similar shade to 0xFF0000, if u need exact color change 10 to 0 I hope this helps Edited August 29, 2017 by toto22 Link to comment Share on other sites More sharing options...
CattBoy Posted August 29, 2017 Author Share Posted August 29, 2017 Understood, but doesn't that make the help document wrong or am I misunderstanding? You're saying the equation is Local $aCoord = PixelSearch(x1, y1, x2, y2, $sColor) effectively the bottom left point of the rectangle is x1,y1 and upper right corner is x2,y2. But reading the help document it lists them as top left corner is x1,y1, button right corner is x2,y2. I'm only asking for clarification since you've said "I think" and don't seem to confident. Testing with both of these are not producing the results I'm expecting. Cheers Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 30, 2017 Moderators Share Posted August 30, 2017 CattBoy, Quote effectively the bottom left point of the rectangle is x1,y1 and upper right corner is x2,y2. No, for various reasons computer display coordinates start at the top left corner, so your statement should read: Quote effectively the top left point of the rectangle is x1,y1 and bottom right corner is x2,y2 M23 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 Link to comment Share on other sites More sharing options...
Malkey Posted August 30, 2017 Share Posted August 30, 2017 The following example shows three different search directions in the same rectangular search area. The middle PixelSearch() is conventionally most commonly used . That is, left to right and top to bottom. #cs ; From PixelSearch - Remarks in AutoIt help file:- The search direction varies as follows: Left-to-Right - left < right Right-to-Left - right < left Top-to-Bottom - top < bottom Bottom-to-Top - bottom < top #ce ; Function - PixelSearch(left, top, right, bottom, color) (Parameters are "left", "top", "right", and, "bottom") ; | | | | Local $aCoord = PixelSearch(480, 930, 1440, 310 , 0xFF0000) ; Note: The desktop's top-left corner is (0, 0) as Melba23 inferred. ; left parameter < right parameter. So search direction is from left to right; and, ; bottom parameter < top parameter, so, search direction also travels from bottom to Top ; Meaning the search starts at the bottom left hand corner and finishes at the top right hand corner. (480, 930) to (1440, 310) corners of rectangular search area. ; If you want the search to start at the top left corner and finish at the bottom right corner use:- Local $aCoord = PixelSearch(480, 310, 930, 1440, 0xFF0000) ; (480, 310) to (930, 1440) corners of rectangular search area. ; Search left to right because left parameter < right parameter, and, search top to bottom because top parameter < bottom parameter. ; If you want the search to start at the bottom right corner and finish at the top left corner use:- Local $aCoord = PixelSearch(930, 1440, 480, 310, 0xFF0000) ; (930, 1440) to (480, 310) corners of rectangular search area. ; Search right to left because right parameter < left parameter, and, search bottom to top because bottom parameter < top parameter. 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