Hooch
Hooch

Reputation: 29693

Image from webbrowser control to picturebox - C#

I have picturebox and webbrowser control. in webbrowser control I'm displaying page with image. This image is visible. I can't pass to picture box url of this image because it will not display. This image is not visible if you enter it's page directy from address bar.

Is there any way to get that image from browser cache or any other way?

I want to get captcha image that appears on this page after viewing one add.

http://www.clix-cents.com/pages/clickads

Upvotes: 1

Views: 4419

Answers (1)

Fun Mun Pieng
Fun Mun Pieng

Reputation: 6901

You can get the image by copying it to the clipboard. JavaScript can copy the img to clipboard.

mshtml.HTMLWindow2Class w2 = webBrowser1.Document.Window.DomWindow as mshtml.HTMLWindow2Class;
w2.execScript("var ctrlRange = document.body.createControlRange();ctrlRange.add(document.getElementById('img1'));ctrlRange.execCommand('Copy');", "javascript");
Image image2 = Clipboard.GetImage();
pictureBox1.Image = image2;

Upvotes: 2

Related Questions