SRL Archive - OSR Help

Move mouse to random position.


ownedlikenoob

2010-06-12 01:31:50

I am working on a script and I need the mouse to move the a random position on the main screen. What would be the command for this?

Something like

MMouse(RandomPosition);

YoHoJo

2010-06-12 01:34:43

MMouse(0, 0, MSX2, MSY2);
is one way to do it.

Ogre

2010-06-12 01:36:33

The parameters for MMouse are

MMouse(x, y, rx, ry: Integer);

rx and ry are the number of random pixels to add

so MMouse(20, 20, 5, 5); would move the mouse to (20 + random(5),20 + random(5))


To find the parameters for a function or procedure, while in SCAR/Simba press ctrl + space and type the name of it.


Edit:ninja'd

Capricorn

2010-06-12 01:56:19

How random do you want it though? The mouse could be at 50, 50 and random could be 50, 50. Probably not exactly what you want, maybe put in a distance check?

YoHoJo

2010-06-12 02:05:46

I need the mouse to move the a random position on the main screen

So MMouse(0, 0, MSX2, MSY2); would move to any random spot on the main screen, it's all good.

marpis

2010-06-12 05:11:13

MouseBox(x1, y1, x2, y2, action: integer);
will move the mouse to somewhere inside box (x1, y1, x2, y2) and do 'action'
  • action = 1 -> Left-Click
  • action = 2 -> Right-Click
  • action = 3 -> Just move, not click

MouseBox(MSX1, MSY1, MSX2, MSY2, 3); Will move the mouse to a random place on the mainscreen.