1 /// <summary>2 ///returns the picture in the specified WebBrowser</IMG>the contents of the diagram in3 /// </summary>4 /// <param name= "Webctl" >WebBrowser Controls</param>5 /// <param name= "Imgetag" >img Element</param>6 /// <returns>img Object</returns>7 PrivateImage getwebimage (WebBrowser webctl, HtmlElement imgetag)8 {9HTMLDocument doc =(HTMLDocument) WebCtl.Document.DomDocument;TenHTMLBody BODY =(HTMLBody) doc.body; OneIhtmlcontrolrange rang =(Ihtmlcontrolrange) Body.createcontrolrange (); AIHTMLControlElement Img = (ihtmlcontrolelement) imgetag.domelement;//Image Address - -Image oldimage =clipboard.getimage (); the Rang.add (IMG); -Rang.execcommand ("Copy",false,NULL);//Copy to Memory -Image Numimage =clipboard.getimage (); - Try + { - clipboard.setimage (oldimage); + } A Catch at { - } - - returnNumimage; -}
Above this code normally can get to the verification code, in some win2003 back problems.
In the previous development, due to the disabling of WebBrowser error prompts, no error prompts, do not know what the cause.
How to: Open IE Internet Options, security--Custom level, allow clipboard for programmatic access, enable this option
Solve the problem that C # can not get by using WebBrowser to intercept CAPTCHA images