Results 1 to 9 of 9

Thread: Randomly click on coordinates.

  1. #1
    Join Date
    May 2008
    Posts
    2
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Randomly click on coordinates.

    Hi, how do I make Simba pick random coordinates from a set of coordinates.

    Lets say if I have points (1,1) (2,2) (3,3) (4,4) (5,5).
    How do I make the script pick randomly two coordinates out of the 5 and click on the coordinates?

  2. #2
    Join Date
    Sep 2012
    Location
    Australia.
    Posts
    839
    Mentioned
    16 Post(s)
    Quoted
    225 Post(s)

    Default

    You can use a case.

    Basically what you'd do (roughly :s):

    Simba Code:
    program Coords;
      {$i SRL/srl.simba}

    procedure RandomCoords;   //Your procedure for clicking the random coords.
    begin
      case Random(50) of
        1..10: ClickStuff;              //Change "ClickStuff, ClickOtherStuff" etc.
        11..20: ClickOtherStuff;        //To your coordinate clicking code.
        21..30: ClickMoreStuff;         //Read this guide on cases: http://villavu.com/forum/showthread.php?t=53840
        31..40: ClickEvenMoreStuff;
        41..50: LetUsClickMoar;
      end;
    end;

    begin
      SetupSRL;
      RandomCoords;  //Using it in mainloop.
    end.

    You can implement that sort of thing into your script. If you need any more help, please post.

  3. #3
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    r:= RandomRange(1, 6);
    Mouse(r, r, 0, 0, mouse_Left);

    OR

    TPA:= [Point(1,1), ....];
    rTP:= TPA[Random(Length(TPA))];
    Mouse(rTP.x, rTP.y, 0, 0, mouse_Left);

  4. #4
    Join Date
    Jul 2012
    Posts
    279
    Mentioned
    5 Post(s)
    Quoted
    46 Post(s)

    Default

    For the sake of it since I have 2 minutes to kill:

    Mouse(TPA[Random(Length(TPA))].x, TPA[Random(Length(TPA))].y, 0, 0, mouse_Left);

    (Just riwu's suggestion put on one line in case you dislike clarity in your scripts).

  5. #5
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    Quote Originally Posted by Wardancer View Post
    For the sake of it since I have 2 minutes to kill:

    Mouse(TPA[Random(Length(TPA))].x, TPA[Random(Length(TPA))].y, 0, 0, mouse_Left);

    (Just riwu's suggestion put on one line in case you dislike clarity in your scripts).
    You can't do that though, since a new number is generated when Random() is called, hence resulting in possibly different index of TPA for the x, y attributes.
    eg.
    TPA[1].x, TPA[3].y
    (unless you actually don't mind about x, y from different TPAs being mixed up)

  6. #6
    Join Date
    Jul 2012
    Posts
    279
    Mentioned
    5 Post(s)
    Quoted
    46 Post(s)

    Default

    Quote Originally Posted by riwu View Post
    You can't do that though, since a new number is generated when Random() is called, hence resulting in possibly different index of TPA for the x, y attributes.
    eg.
    TPA[1].x, TPA[3].y
    (unless you actually don't mind about x, y from different TPAs being mixed up)
    That's what I understood from the OP though when he asked for "two coordinates out of the 5 and click on the coordinates". Doesn't help with clarity when the same word is used for two different meanings in the same sentence though, haha.

  7. #7
    Join Date
    May 2008
    Posts
    2
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Hi, thanks for the reply guys. I tested out the first random function. Not sure if it worked or not, most likely I messed up somewhere. At least it's running...

    Here is my code, please feel free to modify it for me...

    Simba Code:
    Procedure FightKnight;
    var
    x, y:Integer;
    begin

    if FindColorSpiral(x, y, 3274237, 257, 341, 345, 409) and
    FindColorSpiral(x, y, 8215631, 445, 332, 517, 384) then
    begin
    MoveMouse(x, y);

      case Random(50) of
        1..10: ClickMouse(316, 584, 1);              //Change "ClickStuff, ClickOtherStuff" etc.
        11..20: ClickMouse(448, 598, 1);        //To your coordinate clicking code.
        21..30: ClickMouse(316, 584, 1);         //Read this guide on cases: http://villavu.com/forum/showthread.php?t=53840
        31..40: ClickMouse(448, 598, 1);
        41..50: ClickMouse(316, 584, 1);
      end;

    wait(15000)
    MoveMouse(385, 603);
    wait(500)
    ClickMouse(385, 603, 1);
    end;
    end;

    Not even sure how to even use
    Simba Code:
    Mouse(TPA[Random(Length(TPA))].x, TPA[Random(Length(TPA))].y, 0, 0, mouse_Left);

  8. #8
    Join Date
    Feb 2012
    Location
    Discord
    Posts
    3,114
    Mentioned
    37 Post(s)
    Quoted
    538 Post(s)

    Default

    Simba Code:
    Mouse(TPA[Random(Length(TPA))].x, TPA[Random(Length(TPA))].y, 0, 0, mouse_Left);

    //wouldn't work as it would click on a mix of two tpa(s)


    //this would click a random set of cords
    TPA := [(0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5)];
    r := Random(Length(TPA));
    Mouse(TPA[r].x, TPA[r].y, 0, 0 ,Mouse_Left);
    edit: just noticed riwu posted pretty much the same thing. opps

  9. #9
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default

    I'm curious as to what you're using it for, maybe we could help you make something more efficient
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

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
  •