Proyect Rapture
Element Clicked in WebBrowser.
How to determine which Image with ID.
13 June 2017
To determine which Element was clicked.
Public Class Form1

Dim WithEvents IEDoc As System.Windows.Forms.HtmlDocument

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
   WebBrowser1.Navigate("file:///C:/Sistemas/PuraLinkVisualizer/HTML/default.htm")
End Sub

Private Sub WebBrowser1_DocumentCompleted(sender As Object, e As WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted

   Try
      IEDoc = WebBrowser1.Document
   Catch ex As Exception
      MsgBox(ex.Message)
   End Try
End Sub

Private Sub IEDoc_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.HtmlElementEventArgs) Handles IEDoc.MouseDown

If e.MouseButtonsPressed = MouseButtons.Left Then
   Dim ScreenCoord As Point
   ScreenCoord = New Point(MousePosition.X, MousePosition.Y)
   Dim BrowserCoord As Point
   BrowserCoord = WebBrowser1.PointToClient(ScreenCoord)
   Dim elem As HtmlElement
   elem = WebBrowser1.Document.GetElementFromPoint(BrowserCoord)
   MsgBox(elem.GetAttribute("ID"))
End If
End Sub
End Class