Page 1 of 1

Random clicks

Posted: 14 May 2020, 15:13
by Karsen
Hello,
I want to create a script that can generate random click in a certain positions
For example: I want to click on "519:454" or"519:356 ", or"519:985 ", or"519:342"

Thanks in advance,
Example d'image :
Image

Re: Random clicks

Posted: 14 May 2020, 17:22
by francois

Code: Select all

XY= [];
XY[0] =  new Point(796,139);
XY[1] =  new Point(796,208);
XY[2] =  new Point(796,275);
XY[3] =  new Point(796,341);

alea= Algorithms.randomInteger(0, (XY.length-1))

var souris=new Mouse()
souris.move(XY[alea])

souris.click();

Re: Random clicks

Posted: 14 May 2020, 17:34
by Karsen
Thank you so much for your reply
I think I miss explain this
I want to click just once but when every time I click i would like to click in random interval position like I want "X" [796 - 896] and for "Y" [100 - 200]

Thank you again for your help

PS: When I run the script I get an error " Script line 1 : "Mouse" is not a valid position. "

Re: Random clicks

Posted: 15 May 2020, 07:03
by francois
To choose a point inside a rectangle :

Code: Select all

X_mini = 227
Y_mini=183
X_maxi=451
Y_maxi = 512

X_alea= Algorithms.randomInteger(X_mini,X_maxi)
Y_alea= Algorithms.randomInteger(Y_mini,Y_maxi)


XY_alea =  new Point(X_alea,Y_alea);
var souris=new Mouse()
souris.move(XY_alea)

souris.click();