From: xdarkshadowx
I don't quite understand, what does TPA do? is it the 'image' that we're scanning? and how will the bot know where to click if I don't get my x and y coords from the found color? or would I need 2 searches?
handColor:= GetColor(320,580);
if findColorTolerance(TPA, handColor,99,69,356,542, 10) then
begin
InvertTPA(TPA); // idk what to do after here.
mouse(clickX, clickY, 3, 4, true);
end.
FindColorTolerance searches the screen from the top-left position, and will stop once only one instance of that colour is found - you cannot change this. However, what you CAN do is use FindColor
sTolerance to find ALL instances of that colour on the screen. Like FindColorTolerance, it searches from the top-left position. However, we can
invert (make it go back to front [i.e. instead of top-left to bottom-right, we can switch it so it goes bottom-right to top-left]) the TPA.
TPA stands for TPointArray (or array of TPoint). If you were only searching for one colour, you would only need a
x and a
y variable (which is represents a point on your computer screen). However, since we're looking for the colour in multiple locations, we have to store all of these locations in an
array, which means multiple values of the same time (multiple values, i.e. locations, of the same type, i.e. point [or TPoint]).
So, what you'd need is something like:
const
Colour = 0;
Tol = 16;
var
TPA: TPointArray;
begin
// Search the Runescape main screen for the colour 'Colour'.
if(FindColorsTolerance(TPA, Colour, MSX1, MSY1, MSX2, MSY2, Tol)) then
begin
InvertTPA(TPA); // Switch the TPA values around.
Mouse(TPA[0].x, TPA[0].y, 4, 4, mouse_Left); // Left click on the bottom-right most colour.
end;
end.
If you notice, I use TPA[0].x and TPA[0].y. Initially, without inverting the TPA, this would contain the position of the colour found in the top-left most position. Because it stores it in how it is found. Inverting this TPA will then give us the opposite result :)