Code:
<DllImport("user32.dll", CharSet := CharSet.Auto, SetLastError := False)> _
Private Shared Function SendMessage(hWnd As IntPtr, Msg As UInteger, wParam As IntPtr, lParam As IntPtr) As IntPtr
End Function
<DllImport("user32.dll", SetLastError := True)> _
Private Shared Function GetWindow(hWnd As IntPtr, uCmd As UInteger) As IntPtr
End Function
<DllImport("user32.dll", CharSet := CharSet.Auto)> _
Private Shared Function GetClassName(hWnd As IntPtr, lpClassName As StringBuilder, nMaxCount As Integer) As Integer
End Function
Dim handle As IntPtr = WebBrowser1.Handle
Dim className As New StringBuilder(100)
While className.ToString() <> "Internet Explorer_Server" ' your mileage may vary with this classname
handle = GetWindow(handle, 5) ' 5 == child
GetClassName(handle, className, className.Capacity)
End While
Dim lParam As IntPtr = DirectCast((y << 16) Or x, IntPtr) ' X and Y coordinates of the click
Const wParam As IntPtr = IntPtr.Zero
Const downCode As UInteger = &H201 ' change this if you want to simulate Ctrl-Click and such
Const upCode As UInteger = &H202 ' these codes are for single left clicks
SendMessage(handle, downCode, wParam, lParam) ' mousedown
SendMessage(handle, upCode, wParam, lParam) ' mouseup