# Thread: How to make a random mouse click in a little selected square?

1. SRL Junior Member
Join Date
Oct 2014
Location
Belgium
Posts
33
Mentioned
0 Post(s)
Quoted
9 Post(s)

## How to make a random mouse click in a little selected square?

so i manged to do this....

this is what i made so far

program Whine_Grabber;

{\$I SRL-6/SRL.simba} // Be sure to add this to ALL your scripts!

Procedure Whine_Grabber

Var

Wine_Of_Zamorak :Integer;

X, y:Integer;

begin
//This is the DTM of the wine
Wine_Of_Zamorak:= DTMFromString('m1gAAAHic42JgYGhlZGBoBOJeIO4D4n4g7g LiOiAuBeJiIK4A4plAte1A3AXEE4F4BhAvBeJlQDwXiKcA8QQg 1lJTY8hOTGBwtrVliAgIYGirrGSwMTNj4GRnZxAWFGQwNzRkSI mOZhABqiUGMxKJEQAA3+kTVA==');

if
FindDTM(Wine_Of_Zamorak, x, y, 332, 120, 438, 195) then // Looking Location of the wine

// starting this when we find the wine
Begin

mouse(point(x, y), MOUSE_MOVE, MOUSE_HUMAN); //Moving to wine

mouse(point(x, y), MOUSE_Left, MOUSE_HUMAN); //Clicking on the wine

wait(random(3400, 5020)); //Random wait between a and b ms

mouse(point(692, 277), MOUSE_MOVE, MOUSE_HUMAN); //Moving to telegrab Icon I WHANT TO CLICK RANDOMLY TO THIS SO I DONT CLICK ALWAYS ON THE SAME PIXEL

Wait(random(1200, 1600)); //Random wait between a and b ms

mouse(point(692, 277), MOUSE_Left, MOUSE_HUMAN); //Clicking on telegrab Icon I WHANT TO CLICK RANDOMLY TO THIS SO I DONT CLICK ALWAYS ON THE SAME PIXEL

Wait(random(1200, 1600)); //Random wait between a and b ms

mouse(point(379, 185), MOUSE_MOVE, MOUSE_HUMAN); //Moving back to the spawn location of the wine

FreeDTM(Wine_Of_Zamorak); // freeDTM so idk why this is needed.....

end;

end;
Begin

Repeat

Whine_Grabber;

until(False);

end.

2. I believe the randomrange(min, max) function may be what you're looking for.
So you could use for example
mouse(point(690 + randomrange(1, 5), 275 + randomrange(1, 5)), MOUSE_MOVE, MOUSE_HUMAN);

I haven't touched Simba in quite a while, so I'm not sure if that formatting is correct.

you could also generate the random number of x and y before hand, each loop though, and plug in the variables into the mouse function.
Simba Code:
ranx := randomRange(690, 695); rany := randomRange(275, 280); mouse(point(ranx, rany), MOUSE_MOVE, MOUSE_HUMAN);
Last edited by Aspect; 04-08-2018 at 07:20 PM.

3. SRL Junior Member
Join Date
Oct 2014
Location
Belgium
Posts
33
Mentioned
0 Post(s)
Quoted
9 Post(s)

Yoopi told me in teh chat to use these and it works great.

this is what yoopi said to me. mouse(random(690, 694), random(275, 279), MOUSE_MOVE, MOUSE_HUMAN);

4. Originally Posted by RSPS Scripter

Yoopi told me in teh chat to use these and it works great.

this is what yoopi said to me. mouse(random(690, 694), random(275, 279), MOUSE_MOVE, MOUSE_HUMAN);
Try putting code in [SIMBA] Code, you can find it in Advanced. It makes it way easier to read

5. You can also use MouseBox:
Simba Code:
MouseBox(x1, y1, x2, y2: Integer; ClickType: Integer);Moves mouse into a random position in the box. Clicks if told to.