Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Store two mouse.xy positions in Variables to calculate
#1
Yesterday i was trying to get two mouse positions (saved when the macro clicks) and calculate the distance in pixels between those two clicks.
I tried a few different things but none of them worked. How can i extract the needed int values of x and y?


Code:
Copy      Help
mouseClicks += 1;
        if (mouseClicks == 1) { mousePos = mouse.xy; mouseClicks += 1; };
        if (mouseClicks > 1) { mousePos2 = mouse.xy;  wait.ms(MouseWait); mouseClicks = 0; };
        double distance = Point.Subtract(mousePos, mousePos2).Length;

Everything except "Point" looks fine. When hovering on it, LibreAutomate says:
Error: 'Point' is an ambiguous reference between 'System.Drawing.Point' and 'System.Windows.Point'

If Point is the wrong way, is there a function or class for it, maybe even to calculate the distance?
#2
Code:
Copy      Help
POINT mousePos = mouse.xy;
mouse.moveBy(20, 50);
POINT mousePos2 = mouse.xy;

double dist = Math2.Distance(mousePos2, mousePos);
print.it(dist, (int)dist, dist.ToInt(), mousePos2.x - mousePos.x, mousePos2.y - mousePos.y);
#3
Thank you! With Math2.Distance it works.


Forum Jump:


Users browsing this thread: 1 Guest(s)