Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Get Coordinates of Pixels with specific color
#1
Question 
I am trying to find the coordinates of a specific color in a window.
 
Code:
Copy      Help
out
int hwnd=win("MyWindow" "MyWindow")
RECT r; r.left=55; r.top=270; r.right=120; r.bottom=275
ARRAY(int) a
GetWindowRect hwnd &r
if(!GetRectPixels(r a 1)) end "failed"
int row col
for row 0 a.len(2)
    out "row %i" row
    for col 0 a.len(1)
        out "0x%X" a[col row]

The window itself is 1600x1024, and the color always shows up in the same spot.

The rectangle boundaries:
Top Left Corner: 55,270
Top Right Corner: 120,270
Bottom Left Corner: 55,275
Bottom Right Corner: 120,275

The specific color I am looking for is hex color 10EF21 or (R:16 G:239 B:33)

This is a screenshot of the area I am looking for:
[img]data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAD0AAAAFCAYAAAD2S+QpAAAAI0lEQVQ4jWPg0Wn8P9IwA49O43+GV6YjBo96eqRguKdHGgYAuj9S3SYkA6kAAAAASUVORK5CYII=[/img]

The Macro currently spits out over 300k lines, and I can not find the color in the list at all.

Am I using RECT properly, or am I getting the information for a different area?

I need to know where the color 10EF21 starts (X), and where it ends (Y).
It should be only 61x5 pixels at most.

I am unsure if the screenshot is showing up properly, so I am linking it again here
[Image: bar.jpg]
#2
The color will be displayed 0x21EF10, because of flag 1.
Also,
Code:
Copy      Help
GetWindowRect hwnd &r
  overwrites r. Use other variable.
Code:
Copy      Help
RECT rw; GetWindowRect hwnd &rw; OffsetRect &r rw.left rw.top
#3
I have modified the code to:
Code:
Copy      Help
out
int hwnd=win("myWindow" "myWindow")
RECT r; r.left=59; r.top=298; r.right=120; r.bottom=301
ARRAY(int) a
RECT rw; GetWindowRect hwnd &rw; OffsetRect &r rw.left rw.top
if(!GetRectPixels(r a 1)) end "failed"
int row col
for row 0 a.len(2)
    out "row %i" row
    for col 0 a.len(1)
        out F"row:{row} - col:{col} - 0x{a[col row]}"

I also noticed I was using the wrong coordinates. I had the Client instead of the Window coordinates.
#4
If client coordinates, even better, then don't need other RECT variable.
Code:
Copy      Help
MapWindowPoints hwnd 0 +&r 2


Forum Jump:


Users browsing this thread: 1 Guest(s)