Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
help with picking areas
#1
hi, i would like having some help writing a bot that should work like this:

Code:
Copy      Help
check an area, then click a button that matches in colours with the previous area (buttons and first area have the same size)

something that works without picking colours, because first area always changes D:

thx in advance
#2
Macro Macro5
Code:
Copy      Help
int col = pixel(300 35 "Quick Macros") ;; where on the screen will your first point be
int r g b
ColorToRGB(col &r &g &b)

int col2 = pixel(500 35 "Quick Macros") ;;where on the screen will the second point be
int r2 g2 b2
ColorToRGB(col2 &r2 &g2 &b2)

if col1 = col2
,lef 500 35 ;; put your code here to click
#3
Quote:matches in colours

Whole area must match exactly? Or color of single pixel? Or colors of several pixels?

Must search for the second area? Or wait? Or simply compare?
#4
Gintaras Wrote:Whole area must match exactly? Or color of single pixel? Or colors of several pixels?

colors of several pixels


Gintaras Wrote:Must search for the second area? Or wait? Or simply compare?

search for a second area that matches in colors with first one and click on it (i can add coordinates where the matched area should be, 6 different coordinates)

edit:


QM_Expert Wrote:Macro Macro5
Code:
Copy      Help
int col = pixel(300 35 "Quick Macros") ;; where on the screen will your first point be
int r g b
ColorToRGB(col &r &g &b)

int col2 = pixel(500 35 "Quick Macros") ;;where on the screen will the second point be
int r2 g2 b2
ColorToRGB(col2 &r2 &g2 &b2)

if col1 = col2
,lef 500 35 ;; put your code here to click

to add 5 more ares i just put col3 - 4 ecc or i just put col 2 as the whole area where buttons are?
#5
Quote:colors of several pixels

This is the most difficult case.
To compare exact image, could use scan.
To compare single pixel, could use pixel, like QM_Expert did.
Now probably need to call pixel many times.

pixel is quite slow, therefore it is better to use function GetRectPixels to get colors of all pixels in the window into array, and then compare elements of the array. The function is here:

How to get Bitmap bits array (RGB)
#6
Macro Macro1543
Code:
Copy      Help
int w=win("Quick Macros" "QM_Editor") ;;your window

RECT r
GetClientRect w &r ;;get size of client area (ie without caption, border, menu)
MapWindowPoints w 0 +&r 2 ;;convert r to screen coordinates
ARRAY(int) a
if(!GetRectPixels(r a)) end "error" ;;get colors of all pixels in the rectangle

int col=a[300 35] ;;this is like in QM_Experts code, but don't need to call pixel() because we already have colors of all pixels in array a

;compare the color in all 6 other areas
if a[500 35]=col
,out 1
,;lef 500 35 w 1 ;;click
else if a[600 35]=col
,out 2
else if a[700 35]=col
,out 3
;and so on, for all 6 areas


;All coordinates (500, 35, etc) are relative to the client area of the window.

;Color values in a are in different format than with pixel(). Read more in GetRectPixels.

;Tip: To see client coordinates in QM status bar, check "Client" in Options dialog, Record tab.
#7
isnt here a video on how to do from a scratch? :S


Forum Jump:


Users browsing this thread: 1 Guest(s)