Mombu the Microsoft Forum sponsored links

Go Back   Mombu the Microsoft Forum > Microsoft > Windows 2003 Server (TECHNET) > Binding to the events of an existing Internet Explorer session through VBScript - how?
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 30th March 13:23
semjon katatschkow
External User
 
Posts: 1
Default Binding to the events of an existing Internet Explorer session through VBScript - how?


I looked at the MS WebBrowser object and there are some nice events, but I
don't understand how to use them and there is absolutely no information on
the ENTIRE internet incl. the MS site on how to use them in VBScript or
Jscript. There are just some VBA examples. You can never find any vbscripts
on the MS site, no matter what you are searching for!

Ok, so I want to connect to an existing IE session and then listen for
events like DownloadBegin. So I write:

set objShell = CreateObject("Shell.Application")

set objShellWindows = objShell.Windows

Set objIE = objShellWindows.Item(0)

WScript.ConnectObject objIE , "objIE _"


But VBScript says "object is not connected". What the hell? If only MS
provided at least some examples! What good are technologies if nobody knows
how to use them?

I can use the methods and properties of WebBrowser and the Internetexplorer
activex objects, like obj.Navigate, obj.Addressbar etc., they work, but not
the events. Please heeelp!
  Reply With Quote


  sponsored links


2 30th March 17:40
michael harris \(mvp\)
External User
 
Posts: 1
Default Binding to the events of an existing Internet Explorer session through VBScript - how?


Unfortunately, IE is not an object that will work with the ConnectObject
method.

The only way to sink IE host related events (as opposed to DHTML DOM events
of a displayed page) from an external js/vbs client is to create the object
instance originally via the WScript.CreateObject method (2nd arg).

--
Michael Harris
Microsoft MVP Scripting
  Reply With Quote
3 31st March 05:52
mr_unreliable
External User
 
Posts: 1
Default Binding to the events of an existing Internet Explorer sessionthrough VBScript - how?


hi Semjon,

I assume you tried connecting to the events of the "parentwindow"
of the doc object and that didn't work either.

There is one other avenue to try, especially if this is all
running on _your_ system, and you are not some sysadmin attempting
to get this to work on thousands of clients.

If you read ms's support article "How to connect to a running
instance of Internet Explorer":

http://support.microsoft.com/kb/176792

You will find a vb-oriented rendition of the same thing you are
doing with shell.applicaton (shdocvw.dll). At the bottom of
the page, it further says that if this doesn't work for you,
then there is another possibility, and that is adding IE to
the "Running Object Table" (or, "ROT" for short), using a
"browser helper object".

Further, if you look at ms's support article "SAMPLE: IEHelper-
Attaching to Internet Explorer 4.0 by Using a Browser Helper
Object", found here:

http://support.microsoft.com/kb/179230

you will find such a helper object, i.e., the IEHelper.exe
download. Once you download and install the helper object,
(or write one yourself) then you can get IE to register itself
in the ROT.

O.K., now back to scripting. You can attach yourself to an
object in the ROT by using the "GetObject" method, (rather
than CreateObject). And finally, you may be able to sink
events using the wsh/vbs "ConnectObject" method.

Caveat Emptor. I only suggest this as a possibility. I have
not attempted to use it myself.

cheers, jw
__________________________________________________ __________

You got questions? WE GOT ANSWERS!!! ..(but,
no guarantee the answers will be applicable to the questions)
  Reply With Quote
4 31st March 05:52
mr_unreliable
External User
 
Posts: 1
Default Binding to the events of an existing Internet Explorer sessionthrough VBScript - how?


A vb example of what I am talking about may be found here:

http://groups.google.com/group/microsoft.public.inetsdk.programming.webbrowser_ctl/browse_thread/thread/103d68146dc72762/c00e6f8fe4af84e6?lnk=st&q=ie+%22window+handle%22&rnum=5&hl=en#c00e6f8fe4af84e6

If effect, Garcia Francois is getting an IE window from
shell.application, then connecting to that IE window's
events using the mshtml.tlb (the HTMLWindow2 class).

One might assert that if one can do this with vb, then
one ought to be able to do it in vbs also.

cheers, jw
  Reply With Quote
5 31st March 05:52
mr_unreliable
External User
 
Posts: 1
Default Binding to the events of an existing Internet Explorer sessionthrough VBScript - how?


Er, sorry about the confusion, the above reference
is not what I was talking about in the original
posting (i.e., BHO's).

It was the result of searching on different keywords.
Anyway, it is a possible way to get at the IE events.

Even if it is not do-able in "pure" script, one could
write an actX object using the msHTML.tlb, and provide
event interfaces back to script.

cheers, jw
  Reply With Quote
6 31st March 22:03
semjon katatschkow
External User
 
Posts: 1
Default Binding to the events of an existing Internet Explorer session through VBScript - how?


Thanks, but this IEHelper is not compiled, and I am not so much into
compiling. Somebody knows where one could get a compiled dll?

You can actually connect to the WebBrowser ActiveX object and then do all
kinds of malicious things that crash Windows Explorer, because the object is
not intended for these purposes:

set objShell2 = WScript.CreateObject("Shell.Explorer.2")
WScript.GetObject objShell2,"objIE_"

Passing arguments to this object will inevitably make Windows Explorer
unstable and eventually crash it, but it's fun

And yes, after searching for hours, I eventually found an MS site that
stated that connecting to a running instance of IE using wscript.getobject
/connectobject is impossible. However, the event listening functions are
flawed anyway. Tried the following:

Set objIE = WScript.CreateObject("InternetExplorer.Application ","objIE_")


Sub objIE_FileDownload(ActiveDo***ent, Cancel)
objIE.Stop()
WScript.Echo "objIE_FileDownload", FALSE, true
End Sub


Sub objIE_NavigateComplete2(ByVal pDisp, URL)
WScript.Echo "objIE_NavigateComplete2", URL
End Sub


Sub objIE_DownloadBegin()
WScript.Echo "objIE_DownloadBegin", URL
End Sub

Sub objIE_DownloadComplete()
WScript.Echo "objIE_DownloadComplete", URL
End Sub


Sometimes the events fire, sometimes they don't, sometimes they fire at a
totally wrong time, nothing works properly. Back to the designer table, MS
programmers! Fix the bugs! And provide some VBScript examples, goddamnit, I


"mr_unreliable" <kindlyReplyToNewsgroup@notmail.com> schrieb im Newsbeitrag news:uDRbAXTKHHA.448@TK2MSFTNGP04.phx.gbl...
  Reply With Quote


  sponsored links


Reply


Thread Tools
Display Modes




Copyright 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666