I have a webpage loaded in a webbrowser control and there is a hyperlink on it. Now I need the program to automaticly click the hyperlink. Is this possible??
Printable View
I have a webpage loaded in a webbrowser control and there is a hyperlink on it. Now I need the program to automaticly click the hyperlink. Is this possible??
Well, you can use SendKeys to make the scrollbar to the point of where the hyperlink is.
And then you can use the SetCursorPos api function to set the cursor to where the link is.Code:WebBrowser1.SetFocus
SendKeys "{DOWN 15}" 'goes down 15 times
And then to make the mouse click, you can use the mouse_event api function to make the mouse click.Code:Declare Function SetCursorPos Lib "user32.dll" (ByVal _
x As Long, ByVal y As Long) As Long
Usage
Dim retval As Long
retval = SetCursorPos(x, y)
Code:Declare Sub mouse_event Lib "user32.dll" (ByVal _
dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal _
cButtons As Long, ByVal dwExtraInfo As Long)
Const MOUSEEVENTF_LEFTDOWN = &H2
Const MOUSEEVENTF_LEFTUP = &H4
Usage
mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0