473,382 Members | 1,611 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Automating external instances of Internet Explorer in C#

I'm trying to receive events from a running instance of Internet Explorer.
So far I've only been able to receive events from an instance I launch from
code, but I need to receive events from all running instances of Internet
Explorer (I mean those that the user launches himself).

I know this is possible because I did it three months ago. Unfortunately, I
can't find the code. I've already looked at all the Microsoft articles on
automating Internet Explorer, so please don't suggest those links.

Thanks in advance.
Jul 21 '05 #1
12 19545
Hello,

Thanks for your post. As I understand, you want to connect to a running
instance of Internet Explorer. If so, please refer to the KB article 176792.

HOWTO: Connect to a Running Instance of Internet Explorer
http://support.microsoft.com/?id=176792

Hope this helps.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #2
Thanks, but I've already seen this article, as all other Microsoft articles
that deal with connecting to Internet Explorer.

As in this article, I have code that cycles through ShellWindows and gets a
reference to each running instance of Internet Explorer. That's where I
connect to the IE events, but they simply don't fire.
static private SHDocVw.ShellWindows shellWindows = new
SHDocVw.ShellWindowsClass();
static private SHDocVw.DWebBrowserEvents2_BeforeNavigate2EventHan dler
beforeNavigate2;
static private SHDocVw.DWebBrowserEvents2_NewWindow2EventHandler newWindow2;

public static void Main()
{
foreach(SHDocVw.InternetExplorer ie in shellWindows)
{
MessageBox.Show("ie.Location:" + ie.LocationURL);
ie.BeforeNavigate2 += beforeNavigate2;
ie.NewWindow2 += newWindow2;
}
}

The message box displays the URL, but the events simply don't fire.

"Tian Min Huang" <ti******@online.microsoft.com> wrote in message
news:uO**************@cpmsftngxa07.phx.gbl...
Hello,

Thanks for your post. As I understand, you want to connect to a running
instance of Internet Explorer. If so, please refer to the KB article 176792.
HOWTO: Connect to a Running Instance of Internet Explorer
http://support.microsoft.com/?id=176792

Hope this helps.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #3
Hello,

Thanks for your response. Based on my research, I am able to receive the IE
event on my side. I now share the following information with you:

1. You will need to create a WinForm application instead of Console
application.
2. I reviewed your code, it seems that the delegates are not mapped to
methods. Please refer to the following code snippet:

//--------------code snippet----------------------
public class Form1 : System.Windows.Forms.Form
{
static private SHDocVw.ShellWindows shellWindows = new
SHDocVw.ShellWindowsClass();

public Form1()
{
InitializeComponent();

foreach(SHDocVw.InternetExplorer ie in shellWindows)
{
MessageBox.Show("ie.Location:" + ie.LocationURL);
ie.BeforeNavigate2 += new
SHDocVw.DWebBrowserEvents2_BeforeNavigate2EventHan dler(this.ie_BeforeNavigat
e2);
}

public void ie_BeforeNavigate2(object pDisp , ref object url, ref
object Flags, ref object TargetFrameName, ref object PostData, ref object
Headers, ref bool Cancel)
{
MessageBox.Show("event received!");
}
//----------------end of----------------------------

Please check it on your side.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #4
Nope. Your code does exactly what my code does, and it doesn't fire the
event. I'm running Windows 2000 here. I'll test it tonight on Windows XP.
But this solution must work on Windows 2000 as well. Any ideas?

Andy
"Tian Min Huang" <ti******@online.microsoft.com> wrote in message
news:4A**************@cpmsftngxa07.phx.gbl...
Hello,

Thanks for your response. Based on my research, I am able to receive the IE event on my side. I now share the following information with you:

1. You will need to create a WinForm application instead of Console
application.
2. I reviewed your code, it seems that the delegates are not mapped to
methods. Please refer to the following code snippet:

//--------------code snippet----------------------
public class Form1 : System.Windows.Forms.Form
{
static private SHDocVw.ShellWindows shellWindows = new
SHDocVw.ShellWindowsClass();

public Form1()
{
InitializeComponent();

foreach(SHDocVw.InternetExplorer ie in shellWindows)
{
MessageBox.Show("ie.Location:" + ie.LocationURL);
ie.BeforeNavigate2 += new
SHDocVw.DWebBrowserEvents2_BeforeNavigate2EventHan dler(this.ie_BeforeNavigat e2);
}

public void ie_BeforeNavigate2(object pDisp , ref object url, ref
object Flags, ref object TargetFrameName, ref object PostData, ref object Headers, ref bool Cancel)
{
MessageBox.Show("event received!");
}
//----------------end of----------------------------

Please check it on your side.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #5
You're right. It works, but only under XP. I'm not receiving any events
under Windows 2000.

Is there a reason?

"Tian Min Huang" <ti******@online.microsoft.com> wrote in message
news:4A**************@cpmsftngxa07.phx.gbl...
Hello,

Thanks for your response. Based on my research, I am able to receive the IE event on my side. I now share the following information with you:

1. You will need to create a WinForm application instead of Console
application.
2. I reviewed your code, it seems that the delegates are not mapped to
methods. Please refer to the following code snippet:

//--------------code snippet----------------------
public class Form1 : System.Windows.Forms.Form
{
static private SHDocVw.ShellWindows shellWindows = new
SHDocVw.ShellWindowsClass();

public Form1()
{
InitializeComponent();

foreach(SHDocVw.InternetExplorer ie in shellWindows)
{
MessageBox.Show("ie.Location:" + ie.LocationURL);
ie.BeforeNavigate2 += new
SHDocVw.DWebBrowserEvents2_BeforeNavigate2EventHan dler(this.ie_BeforeNavigat e2);
}

public void ie_BeforeNavigate2(object pDisp , ref object url, ref
object Flags, ref object TargetFrameName, ref object PostData, ref object Headers, ref bool Cancel)
{
MessageBox.Show("event received!");
}
//----------------end of----------------------------

Please check it on your side.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #6
Hi,

As stated in my previous reply, it works properly on my Windows 2000
systems. I think more information is needed before moving forward:

1. Did you install .NET Framework 1.1 on your Windows 2000?
2. Did you apply Windows 2000 Service Pack 3?
3. What's the version of IE on your Windows 2000?
4. Please try my sample attached in my previous post.

I am standing by for your response.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #7
Thank you for not abandoning me.

1. I have the .NET Framework 1.0.3705 and 1.1 installed (same as on my XP
system).
2. I have Windows 2000 with Service Pack 4.
3. I have Internet Explorer 6.0.2800.1106 with Service Pack 1 and Q828750.
4. I have tried your code, with the same result.

I know it shouldn't make any difference, but I should mention that on the
Windows 2000 system, I also have Visual Studio 6 installed. I had to go
through extensive tinkering as per the following article
http://msdn.microsoft.com/library/de...us/dnvid/html/
msdn_videbugging.asp
to enable debugging in Interdev.

Also, it just occurred to me that I have Visual Studio .NET Professional
2002 on the Windows 2000 system, and Visual Studio .NET Enterprise Architect
2003 on the XP system.

Thanks again.
"Tian Min Huang" <ti******@online.microsoft.com> wrote in message
news:Kl**************@cpmsftngxa07.phx.gbl...
Hi,

As stated in my previous reply, it works properly on my Windows 2000
systems. I think more information is needed before moving forward:

1. Did you install .NET Framework 1.1 on your Windows 2000?
2. Did you apply Windows 2000 Service Pack 3?
3. What's the version of IE on your Windows 2000?
4. Please try my sample attached in my previous post.

I am standing by for your response.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #8
Hello,

Thanks for your reply. It's strage that I am not able to reproduce the
problem on my Windows 2000 test sytems with similar configuration (Win2K
SP4, IE6 SP1, .NET Framework 1.1). To narrow down the problem, I recommend
you build a new Windows 2000 system with .NET Framework 1.1 and check if
the problem persists on your side.

Hope this helps.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #9
Thanks.

I take back what I said. Your executable works on all the Windows 2000
systems I've tried it on. But when I compile your source code using VS.NET
2002 the event doesn't fire on the two computers that have VS.NET 2002
installed, but it fires on a clean Windows 2000 system with just the .NET
Framework 1.1 installed and no VS.NET.

I will try compiling the same code on XP with VS.NET 2003, then run it on
the same Windows 2000 computers to see if it has to do with VS.NET 2002, but
right now it looks like the culprit.


"Tian Min Huang" <ti******@online.microsoft.com> wrote in message
news:Yz**************@cpmsftngxa07.phx.gbl...
Hello,

Thanks for your reply. It's strage that I am not able to reproduce the
problem on my Windows 2000 test sytems with similar configuration (Win2K
SP4, IE6 SP1, .NET Framework 1.1). To narrow down the problem, I recommend
you build a new Windows 2000 system with .NET Framework 1.1 and check if
the problem persists on your side.

Hope this helps.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #10
Hello,

Thanks a lot for your update. It seems that the application only works on
..NET Framework 1.1. I suggest that you can configure your application to
run against .NET Framework 1.1 only with its .config file looks like:

<configuration>
<startup>
<supportedRuntime version="v1.1.4122"/>
</startup>
</configuration>

Please refer to the following MSDN article for detailed information:
Side-by-Side Execution of the .NET Framework
http://msdn.microsoft.com/library/de...us/dnnetdep/ht
ml/sidexsidenet.asp

Please feel free to let me know if any further is needed.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #11
That did it!

I can't thank you enough for your help. If I had a million dollars, I'd give
it to you. You're my savior!

"Tian Min Huang" <ti******@online.microsoft.com> wrote in message
news:Gw**************@cpmsftngxa07.phx.gbl...
Hello,

Thanks a lot for your update. It seems that the application only works on
.NET Framework 1.1. I suggest that you can configure your application to
run against .NET Framework 1.1 only with its .config file looks like:

<configuration>
<startup>
<supportedRuntime version="v1.1.4122"/>
</startup>
</configuration>

Please refer to the following MSDN article for detailed information:
Side-by-Side Execution of the .NET Framework
http://msdn.microsoft.com/library/de...us/dnnetdep/ht ml/sidexsidenet.asp

Please feel free to let me know if any further is needed.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #12
Thanks a lot for your feedback! :-)

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Mark | last post by:
Hi all, Im written a small javascript program. Once it finishs I want to close the internet explorer page. I have used window.close(); when this runs it pops up with a Internet Explorer Dialog...
6
by: tinkerman | last post by:
Hello net friends, I need to automate Internet Explorer in a very simple way. I need to: 1. press refresh (F5) on the currently loaded website. 2. press END button. 3. Click a button...
10
by: milk-jam | last post by:
I'm trying to write a log which save each time internet explorer is opened or closed and all of the url which where visited? Any help is greatly appreciated.
12
by: SunshineGirl | last post by:
I'm trying to receive events from a running instance of Internet Explorer. So far I've only been able to receive events from an instance I launch from code, but I need to receive events from all...
4
by: attachmatey | last post by:
Greetings: I'm looking for some help in automating (what I thought would be) a simple procedure in Internet Explorer. I'm trying to put the following operation under a button click in an MS...
4
by: redoix | last post by:
Sometimes There To Many Instance Of The Internet Browsing Page Running On The Taskbar. This Slows Down Connection.how Do I Limit The Instances Of Internet Browsers So That One The Limit Is Reached...
3
by: Matthew Lock | last post by:
Hello, I am automating Internet Explorer in order to do some simple automated testing of a web application. How do I invoke Javascript functions in the web page I load? I can successfully start...
1
by: avpkills2002 | last post by:
I seem to be getting this weird problem in Internet explorer. I have written a code for parsing a XML file and displaying the output. The code works perfectly fine with ffx(Firefox).However is not...
0
by: Bill Corry | last post by:
I have been trying to get an instance of internet explorer to navigate to a website using the Navigate2 command. When the navigation request uses the Get method (just a URL) there is no problem. ...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.