Re-Display Image from Webbrowser (VB.NET)
Mei 1, 2011
Example of Purpose:
- Displaying captcha for creating automatic login (such as internet banking BRI: https://ib.bri.co.id/ib-bri/Login.html)
- 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:

