Example of Purpose:

  1. Displaying captcha for creating automatic login (such as internet banking BRI: https://ib.bri.co.id/ib-bri/Login.html)
  2. Automatic System for grabing and saving image from a website
The Code:
    Function GrabImageFromWebBrowser(ByVal Browser As WebBrowser, ByVal ImageIndex As Integer) As Bitmap
        Dim doc As mshtml.IHTMLDocument2 = Browser.Document.DomDocument
        Dim selObj As mshtml.IHTMLSelectionObject = doc.selection
        Dim body As mshtml.HTMLBody = doc.body
        Dim range As mshtml.IHTMLControlRange = body.createControlRange()
        Dim img As mshtml.IHTMLControlElement = Browser.Document.Images(ImageIndex).DomElement

        range.add(img)
        range.select()
        range.execCommand("Copy", False)

        Dim bimg As Bitmap = New Bitmap(Clipboard.GetImage())
        Return bimg
    End Function
References:
  1. http://lazycoders.blogspot.com/2007/06/mshtml-dom-and-copying-objects-from.html
  2. http://www.vbforums.com/showthread.php?t=551127
Ikuti

Get every new post delivered to your Inbox.