I am using mshtml.InternetExplorer object within my winforms application to browse a web application. Somehow I can't use webbrowser in my solution. Now I need to capture screenshot of a div element inside this web application. I see lots of solutions doing similar functionality using webbrowser's drawtobitmap method but none is using mshtml.InternetExplorer. Is there way to achieve this functionality ? Is there some way that I can type cast InternetExplorer object into webbrowser?
Asked
Active
Viewed 623 times
1
-
Not clear, are you automating an out-of-process `InternetExplorer` object or hosting an in-process instance of `WebBrowser` ActiveX control? – noseratio Dec 05 '13 at 01:12
-
I am automating an out-of-process InternetExplorer object. I just do process.start(iexplore.exe) & then automating that ie instance – user435293 Dec 05 '13 at 04:33
1 Answers
0
You should be able to capture the desired part of the main IE window using PrintWindow
Windows API, as explained here. You can get the handle of the window by calling IWebBrowser2::HWND
on the IE object. Some other methods could also help to make this happen:
-
I know this is somewhat late after the question was asked but I implemented exactly the same solution as suggested by you but it is failing randomly on some user' machine.It fails for difft resolution/browser zoom. Isnt there any method like webbrowser's drawtobitmap that will dynamically fetch image given its id ? – user435293 Feb 06 '14 at 10:23
-
@user435293, consider posting a new question with more details, someone else might be able to help better. – noseratio Feb 06 '14 at 10:33