PDA

View Full Version : Click only within the bound of a TPA?



Brotein
06-29-2014, 04:09 PM
I'm not sure how to do this. I would like to click on a specific area of an object, like in this picture.
http://i.imgur.com/rU172Su.png

I can't split the TPA because the object color is not all that unique and is already separated from it's surroundings(not nearly as clean as the picture :() Changing the split size will not guarantee the object's clickable area is in a TPA of it's own.

So let's say I create a TPoint called P and give it, which will return me 10,50.
p := middleTPA(ObATPA[i]);

Right now I edit the point with a static offset, but sometimes the colors change throwing off the y coordinate making it not hover where I want it to.

How can I grab the Y position of the top border of the TPA. So in the picture I want to grab the Y coordinate of the highest border, in this case it would be 0. This way I can edit my point's Y value to always click say 10 points below that point no matter what. This way I will only move the mouse onto the clickable area.

rj
06-29-2014, 04:40 PM
Y Position of top border:

function getY(tpa:TPointArray):integer;
var
b:Tbox;
begin
b := getTpaBounds(tpa);
result := b.y1;
end;

This function will click within a certain point inside the TPA:

procedure clickPointInsideTPA(tpa:TPointArray;pnt:TPoint);
var
b:Tbox;
begin
b := getTpaBounds(tpa);
mouse(b.x1 + pnt.x, b.y1 + pnt.y, 0, 0, mouse_left);
end;

So if you wanted to click the top left of the TPA you would do:


clickPointInsideTPA(tpa, Point(0, 0));

Or 10 points below the top Y


clickPointInsideTPA(tpa, Point(0, 10));

Sin
06-29-2014, 05:59 PM
Alternatively, you can use MouseBox();
MouseBox will click at a random point in the box provided. So you'd do something like

MouseBox(getTPABounds(TPA).x1, getTPABounds(TPA).y1, getTPABounds(TPA).x2, getTPABounds(TPA).y2, mouse_Left);
Clean it up of course, don't leave it like that.

Brotein
06-29-2014, 08:44 PM
Y Position of top border:

function getY(tpa:TPointArray):integer;
var
b:Tbox;
begin
b := getTpaBounds(tpa);
result := b.y1;
end;

This function will click within a certain point inside the TPA:

procedure clickPointInsideTPA(tpa:TPointArray;pnt:TPoint);
var
b:Tbox;
begin
b := getTpaBounds(tpa);
mouse(b.x1 + pnt.x, b.y1 + pnt.y, 0, 0, mouse_left);
end;

So if you wanted to click the top left of the TPA you would do:


clickPointInsideTPA(tpa, Point(0, 0));

Or 10 points below the top Y


clickPointInsideTPA(tpa, Point(0, 10));

This does the trick, thanks!