Mouse random move and click only on box

03/24/2016 10:02 joshxp#1
hello,
i want to ask something.
i need the code for mouse random move and click so just like this :
Move > click > Keys > Click and repeat.
i already made 1 just like this :

Code:
HotKeySet("{F1}", "Start")
HotKeySet("{F2}", "Stop")

while  1 = 1
WEnd

Func Stop()
   Exit
EndFunc

Func Start()
   While 1 = 1
$moveX = random (1,500,1)
$moveY = random (1,500,1)
Mouseclick("left",$moveX,$MoveY,1,20)
Sleep (100)
Send ("2")
Sleep (100)
Mouseclick("left",$moveX,$MoveY,1,20)
WEnd
EndFunc
But, the mouse still move into outside the box,
i used it for Ragnarok Online. :D

Thank's
03/24/2016 11:13 alpines#2
You have to place the window in that position to do it this way. Otherwise I would recommend you to get the position of the window and use it as an offset for your random-x and random-y values so they start at that point and end after offset+500 (I would suggest to adjust the 500 value too since I don't think the window is 500/500 big is it?)
03/24/2016 12:16 °Incinerate#3
As alpines said. The random retunds u from 1 to 500 but i dont think that yout box is in this area. So i have modified your script. Just do what i write in the messagebox.

Code:
#include <Misc.au3>

HotKeySet("{F1}", "Start")
HotKeySet("{F2}", "Stop")

Global $TopLeft, $BottomRight, $dll, $left, $bottom, $top, $right
$dll = DllOpen("user32.dll")

;~~~ set the area of your box
MsgBox(0, "TopLeft", "Put the mouse top left of your box and press then F8.")
While Not _IsPressed("77", $dll)
	$pos = MouseGetPos()
	ToolTip($pos[0] & " x " & $pos[1])
	Sleep(10)
WEnd
$top = $pos[1]
$left = $pos[0]
MsgBox(0, "TopLeft", $pos[0] & " x " & $pos[1] &  [MENTION=3576271]CRLF[/MENTION] &  [MENTION=3576271]CRLF[/MENTION] & "Put the mouse bottom right of your box and press then F8.")


While Not _IsPressed("77", $dll)
	$pos = MouseGetPos()
	ToolTip($pos[0] & " x " & $pos[1])
	Sleep(10)
WEnd
$bottom = $pos[1]
$right = $pos[0]
MsgBox(0, "BottomRight", $pos[0] & " x " & $pos[1] &  [MENTION=3576271]CRLF[/MENTION] &  [MENTION=3576271]CRLF[/MENTION] & "Now you can start you bot with F1 and end it with F2.")
;~~~ until here

;~~~ your modified script
While  1 = 1
	Sleep(10)
WEnd

Func Stop()
   Exit
EndFunc

Func Start()
   While 1 = 1
	$moveX = Random($left, $right, 1)
	$moveY = Random($top, $bottom, 1)
	Mouseclick("left", $moveX, $moveY, 1, 20)
	Sleep (100)
	Send ("2")
	Sleep (100)
	Mouseclick("left", $moveX, $moveY, 1, 20)
	WEnd
EndFunc
;~~~ until here