IE.Visible = false; But it actually shows ? c#

user198989 picture user198989 · Aug 28, 2015 · Viewed 9k times · Source

I am trying to navigate ie invisibly, tried this

SHDocVw.InternetExplorer IE = new SHDocVw.InternetExplorer();
IE.Visible = false;
IE.Navigate("http://example.org");

Works, however, it actually shows the IE window. What is the best approach to hide the IE window ?

Answer

PaulF picture PaulF · Aug 28, 2015

From the docs : "When the Windows Internet Explorer application is first created, it is hidden. It becomes visible after the Navigate method or the GoSearch method is used."

Set Visible AFTER navigating.

https://msdn.microsoft.com/en-us/library/aa752082(v=vs.85).aspx

http://forums.codeguru.com/showthread.php?512303-SHDocVw-InternetExplorerClass-visible-property-to-False-does-not-work-on-some-machine It seems that the NavigateComplete event also makes the window visible, so it should also be hidden in a handler for that event as well.