Results 1 to 6 of 6

Thread: TPA question

  1. #1
    Join Date
    Oct 2017
    Posts
    5
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default TPA question

    Question regarding TPAs (from a beginner):

    I am using the following to find a colour on my screen:
    Code:
    color.findAllIn(AREA_MS, point);
    Once the colour has been found, I want to move my mouse using HumanMMouse to a random location within all the coordinates stored in the TPA "point".

    How can I define such a random location?

    Thanks.

  2. #2
    Join Date
    Jun 2013
    Location
    Scranton
    Posts
    496
    Mentioned
    5 Post(s)
    Quoted
    220 Post(s)

    Default

    Untested but this should do it (you should probably check to make sure your tpa length is greater than 0)

    Simba Code:
    Function TPointArray.Random(): TPoint;
    Begin
      result := self[RandomRange(0, Length(self) - 1)];
    End;  

    ...

    HumanMMouse(point.Random(), 0, 0);
    Last edited by jstemper; 11-15-2017 at 02:15 AM. Reason: example

  3. #3
    Join Date
    Oct 2017
    Posts
    5
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Seems to work great so far. Thanks alot.

    I have another question maybe you can answer too.

    If I were to use the function I previously mentioned and use HumanMMouse with that TPA, it will move the mouse to the first coordinates found the the TPA "point". Is there a way to extract the coordinates out of this point, i.e. to know what the first coordinates of the TPA are? Or to store the X and Y coordinates in 2 different integers to use them later?

  4. #4
    Join Date
    Jun 2013
    Location
    Scranton
    Posts
    496
    Mentioned
    5 Post(s)
    Quoted
    220 Post(s)

    Default

    Quote Originally Posted by baloine View Post
    Seems to work great so far. Thanks alot.

    I have another question maybe you can answer too.

    If I were to use the function I previously mentioned and use HumanMMouse with that TPA, it will move the mouse to the first coordinates found the the TPA "point". Is there a way to extract the coordinates out of this point, i.e. to know what the first coordinates of the TPA are? Or to store the X and Y coordinates in 2 different integers to use them later?
    I'm not too sure what you mean by extract the coordinates out of the point. You can access the x and y like so; TPoint.X, TPoint.Y. To save it for later just store it in a variable

  5. #5
    Join Date
    Jan 2012
    Location
    Sydney, Australia
    Posts
    877
    Mentioned
    12 Post(s)
    Quoted
    368 Post(s)

    Default

    Simba Code:
    Function TPointArray.Random(): TPoint;
    Begin
      result := self[RandomRange(0, Length(self) - 1)];
    End;

    ...

    pnt := point.random();
    HumanMMouse(pnt, 0, 0);
    writeln('X axis: ', pnt.x);
    writeln('Y axis: ', pnt.y);

  6. #6
    Join Date
    Oct 2017
    Posts
    5
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    This is exactly what I was looking for. Didn't know you could get the X and Y coordinates by adding .X and .y
    Thanks

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •