Making VB use mouse moving and clicking

How would I make Visual Basic 5 move the mouse to a certain position say , inside of a web browser window , like at the web page and then click on a certain xy coordinates every say 2.5 seconds.. Or would it be easier to type in the URL in the location area and have it hit enter every 2.5 seconds.. Please email the reply to ADMLN@polbox.com as i do not frequent this website..
itsphattyAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
y2kwackoConnect With a Mentor Commented:
The point of this place is to do it so that others can get the answer as well, as such I will post it here

you can do both as for setting the mouse coords

SetCursorPos

Declare Function SetCursorPos Lib "user32" Alias "SetCursorPos" (ByVal x As Long, ByVal y As Long) As Long


as for clicking you can use the mouse_event API Function

Declare Sub mouse_event Lib "user32" Alias "mouse_event" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
 

0
 
itsphattyAuthor Commented:
Thanks a lot it really helped
0
 
y2kwackoCommented:
your welcome
0
 
itsphattyAuthor Commented:
What stuff do I type in to make the mouse click at coordinated 600x and 400x and have it click the left mouse button? I am kinda new to this and I do not understand the mouse_event function all the way.. Can you please type it in a new comment and have it all typed out how I would need it to click the left mouse button at 600x 400y .. Hope you can help.. Also tell me how to use sendkeys , I used to know but I forgot after being gone from programming for a while.. I need it to like click on an area and then type something in, then click on like a non-vb button.. I think I can get it to work but for now just tell me mouse_event and sendkeys.. Thanks a lot..
0
 
y2kwackoCommented:
call mouse_event(flags,600,400,0,0)

for more info read the bottom

----takin from the win32 API docs----

The mouse_event function synthesizes mouse motion and button clicks.

VOID mouse_event(

    DWORD dwFlags,      // flags specifying various motion/click variants
    DWORD dx,      // horizontal mouse position or position change
    DWORD dy,      // vertical mouse position or position change
    DWORD dwData,      // amount of wheel movement
    DWORD dwExtraInfo       // 32 bits of application-defined information
   );      
 

Parameters

dwFlags

A set of flag bits that specify various aspects of mouse motion and button clicking. The bits in this parameter can be any reasonable combination of the following values:

Value      Meaning
MOUSEEVENTF_ABSOLUTE      Specifies that the dx and dy parameters contain normalized absolute coordinates. If not set, those parameters contain relative data: the change in position since the last reported position. This flag can be set, or not set, regardless of what kind of mouse or mouse-like device, if any, is connected to the system. For further information about relative mouse motion, see the following Remarks section.
MOUSEEVENTF_MOVE      Specifies that movement occurred.
MOUSEEVENTF_LEFTDOWN      Specifies that the left button changed to down.
MOUSEEVENTF_LEFTUP      Specifies that the left button changed to up.
MOUSEEVENTF_RIGHTDOWN      Specifies that the right button changed to down.
MOUSEEVENTF_RIGHTUP      Specifies that the right button changed to up.
MOUSEEVENTF_MIDDLEDOWN      Specifies that the middle button changed to down.
MOUSEEVENTF_MIDDLEUP      Specifies that the middle button changed to up.
MOUSEEVENTF_WHEEL      Windows NT only: Specifies that the wheel has been moved, if the mouse has a wheel. The amount of movement is given in dwData
 

The flag bits that specify mouse button status are set to indicate changes in status, not ongoing conditions. For example, if the left mouse button is pressed and held down, MOUSEEVENTF_LEFTDOWN is set when the left button is first pressed, but not for subsequent motions. Similarly, MOUSEEVENTF_LEFTUP is set only when the button is first released.

dx

Specifies the mouse's absolute position along the x-axis or its amount of motion since the last mouse event was generated, depending on the setting of MOUSEEVENTF_ABSOLUTE. Absolute data is given as the mouse's actual x-coordinate; relative data is given as the number of mickeys moved.

dy

Specifies the mouse's absolute position along the y-axis or its amount of motion since the last mouse event was generated, depending on the setting of MOUSEEVENTF_ABSOLUTE. Absolute data is given as the mouse's actual y-coordinate; relative data is given as the number of mickeys moved.

dwData

If dwFlags is MOUSEEVENTF_WHEEL, then dwData specifies the amount of wheel movement. A positive value indicates that the wheel was rotated forward, away from the user; a negative value indicates that the wheel was rotated backward, toward the user. One wheel click is defined as WHEEL_DELTA, which is 120.
If dwFlags is not MOUSEEVENTF_WHEEL, then dwData should be zero.

dwExtraInfo

Specifies an additional 32-bit value associated with the mouse event. An application calls GetMessageExtraInfo to obtain this extra information.

 

Return Values

This function has no return value.

Remarks

If the mouse has moved, indicated by MOUSEEVENTF_MOVE being set, dx and dy hold information about that motion. The information is given as absolute or relative integer values.
If MOUSEEVENTF_ABSOLUTE value is specified, dx and dy contain normalized absolute coordinates between 0 and 65,535. The event procedure maps these coordinates onto the display surface. Coordinate (0,0) maps onto the upper-left corner of the display surface, (65535,65535) maps onto the lower-right corner.

If the MOUSEEVENTF_ABSOLUTE value is not specified, dx and dy specify relative motions from when the last mouse event was generated (the last reported position). Positive values mean the mouse moved right (or down); negative values mean the mouse moved left (or up).
Relative mouse motion is subject to the effects of the mouse speed and the two mouse threshold values. In Windows NT, an end user sets these three values with the Mouse Tracking Speed slider of Control Panel's Mouse option; in Windows 95, an end user sets them with the Pointer Speed slider of the Control Panel's Mouse property sheet. An application obtains and sets these values with the SystemParametersInfo function.

The operating system applies two tests to the specified relative mouse motion. If the specified distance along either the x or y axis is greater than the first mouse threshold value, and the mouse speed is not zero, the operating system doubles the distance. If the specified distance along either the x or y axis is greater than the second mouse threshold value, and the mouse speed is equal to two, the operating system doubles the distance that resulted from applying the first threshold test. It is thus possible for the operating system to multiply relatively-specified mouse motion along the x or y axis by up to four times.

The mouse_event function is used to synthesize mouse events by applications that need to do so. It is also used by applications that need to obtain more information from the mouse than its position and button state. For example, if a tablet manufacturer wants to pass pen-based information to its own applications, it can write a dynamic-link library (DLL) that communicates directly to the tablet hardware, obtains the extra information, and saves it in a queue. The DLL then calls mouse_event with the standard button and x/y position data, along with, in the dwExtraInfo parameter, some pointer or index to the queued extra information. When the application needs the extra information, it calls the DLL with the pointer or index stored in dwExtraInfo, and the DLL returns the extra information.
0
All Courses

From novice to tech pro — start learning today.