Solved

Automating Internet Explorer with C#.net

Posted on 2004-10-01
8
435 Views
Last Modified: 2008-01-09
How can I programmatically start up IE and navigate to a specific URL using C#?
0
Comment
Question by:cvfn
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 15

Expert Comment

by:praneetha
ID: 12203487
r u talking about windows or web application?
0
 

Author Comment

by:cvfn
ID: 12203500
Windows

Thanks,
Melody
0
 
LVL 15

Expert Comment

by:praneetha
ID: 12203531
System.Diagnostics.Process.Start("IExplore.exe", "www.google.com");
0
 

Author Comment

by:cvfn
ID: 12203775
Thanks you for the quick reply. Can I access IE as a com object after starting it this way?

Melody
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 15

Expert Comment

by:praneetha
ID: 12203821
http://www.codeproject.com/csharp/runninginstanceie.asp

see if that helps...i am not much of a windows person

0
 
LVL 1

Expert Comment

by:CrazyIvan007
ID: 12203888
Start InternetExplorer (as said from praneetha), then use AxSHDocVw and MSHTML to access the WebBrowser

SHDocVw.InternetExplorer browser = null;
string filnam;
 
SHDocVw.ShellWindows shellWindows =      new SHDocVw.ShellWindowsClass();
   
foreach (SHDocVw.InternetExplorer ie in shellWindows)
{
      filnam = Path.GetFileNameWithoutExtension(ie.FullName).ToLower();
 
      if (filnam.Equals("iexplore"))
      {
                     browser = ie;
                               object o = null;
                               browser.Navigate("http://www.yourpage.com/", ref o, ref o, ref o, ref o);
                               break;
      }
}

For this you have to set References to AxSHDocVw, SHDocVw and MSHTML. To get more informations about how to access the browser component look at

http://www.codeproject.com/csharp/webbrowser.asp
0
 
LVL 3

Accepted Solution

by:
zstafa earned 250 total points
ID: 12205932
1. Open a new windows app
2. drag a button on to the form
3. Double click on it
4. Paste this into it.

                        object o = null;

                        SHDocVw.InternetExplorer ie = new
                              SHDocVw.InternetExplorerClass();

                        IWebBrowserApp wb = (IWebBrowserApp) ie;
                        wb.Visible = true;

                        wb.Navigate("www.google.com", ref o, ref o, ref o, ref o);


5. Right click on references and click add the SHDocVw.dll reference in windows/system32
6.make sure to add "Using SHDocvw;"    at the top

0
 
LVL 3

Expert Comment

by:zstafa
ID: 12205942
Sorry what do you want to do with the IE window after you access it?
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now