Jump to content


Photo

Simultaneous Actions


  • Please log in to reply
2 replies to this topic

#1 Pepperonio

Pepperonio
  • Members
  • 21 posts

Posted 15 May 2012 - 08:16 AM

I am trying to do two things simultaneously in 1 script:

1) Moving mouse randomly and continuously between 2 points, during which
2) the mouse performs randomized drags/releases.

I can do those tasks seperately, but am having trouble performing them at the same time. I probably can do it with 2 seperate scripts running simultaneously, but can anyone here please give me some hint on how to do it in 1 script?

Here are the two loops:

Loop 1, random movements:
Loop
{

	;get a random point where the mouse moves to
	Random, Dest, MinX, MaxX

	;Move the mouse to there, with slow (100) speed
	MouseMove, Dest, MouseY, 100

}

Loop 2, random draggings
Click down
Loop
{

	Random, ClickRelease, 0, 99
	If (ClickRelease > 90)
	{
		Click up
		Sleep 200
		Click down
	}
	else
	{
		sleep 200
	}


}
Click up


#2 CodeKiller

CodeKiller
  • Members
  • 2066 posts

Posted 15 May 2012 - 10:04 AM

Try something like :

F1::
; Loop
; {
	MouseY := 200
	MinX := 100
	MaxX := 700
	MidPoint := (MaxX - MinX) / 2
	Random FirstPoint, MinX + 50, MidPoint
	Random SecondPoint, MidPoint, MaxX - 50
	Msgbox %FirstPoint% - %MidPoint% - %SecondPoint%
	MouseMove FirstPoint, MouseY, 100
	Random ClickRelease, 0, 99
	If (ClickRelease < 90)
	{
		Click Down
		MouseMove SecondPoint, MouseY, 100
		Click Up
	}
	MouseMove MaxX, MouseY, 100
; }
Return

Try it in mspaint to see what it does.

#3 Pepperonio

Pepperonio
  • Members
  • 21 posts

Posted 16 May 2012 - 04:50 AM

Thanks you for your reply! Yes your solution does what I needed! Thank you!