# Visual Basic Random Move / Click

Currently I have a program that will click in a specific coordinate. What I want to know is if it's possible for vb to randomly move / click in a spot. This is what I have so far, and it works with moving to the (Area). The total area of the object is TopLeft: 115, 734 and BottomRight: 153,763. So if possible can I tell it to move and click anywere from 115,734 & 153, 763. Thanks.

Dim Area = (New Point(Val(135), Val(747)))

AppActive("Current App Focus Needed I guess")

MouseMoveTo(Area)
LVL 1
###### Who is Participating?

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
Have look at these, you can take out the timer stuff, or at least easily pick out how they are doing the mouseclick (the basic concept is they send window messages indicatingg various facts about the mouse click):

http://www.codeproject.com/KB/system/Auto_Clicker.aspx
http://www.codeproject.com/KB/cs/Auto_Clicker_Bar.aspx

http://www.dreamincode.net/forums/topic/67915-helpauto-clicker-vb2008/
0
Author Commented:
So I could do the following then? Was hopeing to make it where I could just say here is a list of x, y coordinates use these at random times.

Dim Area = (New Point(Val(135), Val(747)))
Dim Area2 = (New Point(Val(136), Val(748)))
Dim A As Integer

AppActive("Current App Focus Needed I guess")

If A = 0 Then
MoveMouseTo(Area)
A = A + 1
' insert mouse click command
Else
MoveMouseTo(Area2)
A = 0
' insert mouse click command
End If
0
High School Computer Science, Computer Applications, and Mathematics TeachersCommented:
You can do something like this:

MoveMouseToArea(New Point(115, 734), New Point(153, 763))

Using this Sub:
Private Sub MoveMouseToArea(ByVal TopLeft As Point, ByVal BottomRight As Point)
Static R As New Random
MoveMouseTo(New Point(R.Next(TopLeft.X, BottomRight.X + 1), R.Next(TopLeft.Y, BottomRight.Y+1))
End Sub
0

Experts Exchange Solution brought to you by