[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

How to determine supported dispinterfaces for WIN32OLE object?

Will Gwaltney

10/6/2004 3:39:00 PM

I'm using WIN32OLE_EVENT to set up some event handlers on various DHTML
elements in Internet Explorer, and I'm having a bit of trouble identifying
the right event dispinterfaces to use. The Microsoft online documentation
is less than helpful; they claim that you can use the HTMLElementEvents2
interface on most all the HTML elements you care about, but I'm getting the
following when I try:

interface not found
HRESULT error code:0x80004002
No such interface supported

Here's a code skeleton that outlines what I'm trying to do:

---------------- (snip) -----------------------

require 'win32ole'

ie = WIN32OLE.new('InternetExplorer.Application')

.
.
.
insert code to display a web page here...
.
.
.

elements = ie.document.all
elements.each do |element|
ev = WIN32OLE_EVENT.new(element, 'HTMLElementEvents2')
.
.
.
assign event handlers here
.
.
.
end

---------------- (snip) -----------------------

And here's the URL for the Microsoft documentation that makes the claims
about the HTMLElementEvents2 interface:
http://msdn.microsoft.com/workshop/browser/mshtml/tutorial...

What am I missing? Do I have to somehow massage the element into a
different object that will handle the HTMLElementEvents2 interface? Or
should I be using another interface entirely? (BTW, is there any way in
WIN32OLE to figure out which interfaces an object supports?)

Any help will be much appreciated!

Will Gwaltney
SAS Institute


4 Answers

gjenkins

10/7/2004 12:20:00 PM

0

The HTMLElementEvents2 interface appears to be supported by
"non-functional" elements such as SPAN, DIV, P. See
http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/mshtml/reference/events/...
for other interfaces - such as HTMLAnchorEvents.

ie.document.all.each { |element|
if element.tagName == 'A'
ev = WIN32OLE_EVENT.new(element, 'HTMLAnchorEvents')
ev.on_event {|*args|
p args
}
end
}

"Will Gwaltney" <will.gwaltney@sas.com> wrote in message news:<ck13hq$fog$1@license1.unx.sas.com>...
> I'm using WIN32OLE_EVENT to set up some event handlers on various DHTML
> elements in Internet Explorer, and I'm having a bit of trouble identifying
> the right event dispinterfaces to use. The Microsoft online documentation
> is less than helpful; they claim that you can use the HTMLElementEvents2
> interface on most all the HTML elements you care about, but I'm getting the
> following when I try:
>
> interface not found
> HRESULT error code:0x80004002
> No such interface supported
>
> Here's a code skeleton that outlines what I'm trying to do:
>
> ---------------- (snip) -----------------------
>
> require 'win32ole'
>
> ie = WIN32OLE.new('InternetExplorer.Application')
>
> .
> .
> .
> insert code to display a web page here...
> .
> .
> .
>
> elements = ie.document.all
> elements.each do |element|
> ev = WIN32OLE_EVENT.new(element, 'HTMLElementEvents2')
> .
> .
> .
> assign event handlers here
> .
> .
> .
> end
>
> ---------------- (snip) -----------------------
>
> And here's the URL for the Microsoft documentation that makes the claims
> about the HTMLElementEvents2 interface:
> http://msdn.microsoft.com/workshop/browser/mshtml/tutorial...
>
> What am I missing? Do I have to somehow massage the element into a
> different object that will handle the HTMLElementEvents2 interface? Or
> should I be using another interface entirely? (BTW, is there any way in
> WIN32OLE to figure out which interfaces an object supports?)
>
> Any help will be much appreciated!
>
> Will Gwaltney
> SAS Institute

Will Gwaltney

10/7/2004 2:48:00 PM

0

Thanks for the reply, Graham. As near as I can tell, the page you mention
on the Microsoft site has *most* of the interfaces, but not all of them
(thanks, Microsoft...) I couldn't figure out which interfaces to use for
submit and reset buttons and a few others. So one of the things I've been
trying to figure out is how to get Ruby to tell me which interfaces a
particular element supports. I know the
IConnectionPointContainer::EnumConnectionPoints method in C++ will get me
that info, but I don't know how to call it from WIN32OLE. Things are
getting desperate; I might have to resort to using VB! :-)

Will

"Graham Jenkins" <gjenkins@xchanging.com> wrote in message
news:e249d8e7.0410070419.113506fc@posting.google.com...
> The HTMLElementEvents2 interface appears to be supported by
> "non-functional" elements such as SPAN, DIV, P. See
>
http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/mshtml/reference/events/...
> for other interfaces - such as HTMLAnchorEvents.
>
> ie.document.all.each { |element|
> if element.tagName == 'A'
> ev = WIN32OLE_EVENT.new(element, 'HTMLAnchorEvents')
> ev.on_event {|*args|
> p args
> }
> end
> }
>
> "Will Gwaltney" <will.gwaltney@sas.com> wrote in message
news:<ck13hq$fog$1@license1.unx.sas.com>...
> > I'm using WIN32OLE_EVENT to set up some event handlers on various DHTML
> > elements in Internet Explorer, and I'm having a bit of trouble
identifying
> > the right event dispinterfaces to use. The Microsoft online
documentation
> > is less than helpful; they claim that you can use the HTMLElementEvents2
> > interface on most all the HTML elements you care about, but I'm getting
the
> > following when I try:
> >
> > interface not found
> > HRESULT error code:0x80004002
> > No such interface supported
> >
> > Here's a code skeleton that outlines what I'm trying to do:
> >
> > ---------------- (snip) -----------------------
> >
> > require 'win32ole'
> >
> > ie = WIN32OLE.new('InternetExplorer.Application')
> >
> > .
> > .
> > .
> > insert code to display a web page here...
> > .
> > .
> > .
> >
> > elements = ie.document.all
> > elements.each do |element|
> > ev = WIN32OLE_EVENT.new(element, 'HTMLElementEvents2')
> > .
> > .
> > .
> > assign event handlers here
> > .
> > .
> > .
> > end
> >
> > ---------------- (snip) -----------------------
> >
> > And here's the URL for the Microsoft documentation that makes the claims
> > about the HTMLElementEvents2 interface:
> > http://msdn.microsoft.com/workshop/browser/mshtml/tutorial...
> >
> > What am I missing? Do I have to somehow massage the element into a
> > different object that will handle the HTMLElementEvents2 interface? Or
> > should I be using another interface entirely? (BTW, is there any way in
> > WIN32OLE to figure out which interfaces an object supports?)
> >
> > Any help will be much appreciated!
> >
> > Will Gwaltney
> > SAS Institute


paul.rogers

10/8/2004 3:02:00 AM

0

Will, can I ask what you aredoing with these interfaces? Im working on
a new version of some code that we use to test web applications via
IEs OLE interface and DOM.
One of the things Im hoping to do is a script recorder, and these
events would be essential in letting me recoed a users actions

Thanks

Paul


"Will Gwaltney" <will.gwaltney@sas.com> wrote in message news:<ck3ku6$m36$1@license1.unx.sas.com>...
> Thanks for the reply, Graham. As near as I can tell, the page you mention
> on the Microsoft site has *most* of the interfaces, but not all of them
> (thanks, Microsoft...) I couldn't figure out which interfaces to use for
> submit and reset buttons and a few others. So one of the things I've been
> trying to figure out is how to get Ruby to tell me which interfaces a
> particular element supports. I know the
> IConnectionPointContainer::EnumConnectionPoints method in C++ will get me
> that info, but I don't know how to call it from WIN32OLE. Things are
> getting desperate; I might have to resort to using VB! :-)
>
> Will
>
> "Graham Jenkins" <gjenkins@xchanging.com> wrote in message
> news:e249d8e7.0410070419.113506fc@posting.google.com...
> > The HTMLElementEvents2 interface appears to be supported by
> > "non-functional" elements such as SPAN, DIV, P. See
> >
> http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/mshtml/reference/events/...
> > for other interfaces - such as HTMLAnchorEvents.
> >
> > ie.document.all.each { |element|
> > if element.tagName == 'A'
> > ev = WIN32OLE_EVENT.new(element, 'HTMLAnchorEvents')
> > ev.on_event {|*args|
> > p args
> > }
> > end
> > }
> >
> > "Will Gwaltney" <will.gwaltney@sas.com> wrote in message
> news:<ck13hq$fog$1@license1.unx.sas.com>...
> > > I'm using WIN32OLE_EVENT to set up some event handlers on various DHTML
> > > elements in Internet Explorer, and I'm having a bit of trouble
> identifying
> > > the right event dispinterfaces to use. The Microsoft online
> documentation
> > > is less than helpful; they claim that you can use the HTMLElementEvents2
> > > interface on most all the HTML elements you care about, but I'm getting
> the
> > > following when I try:
> > >
> > > interface not found
> > > HRESULT error code:0x80004002
> > > No such interface supported
> > >
> > > Here's a code skeleton that outlines what I'm trying to do:
> > >
> > > ---------------- (snip) -----------------------
> > >
> > > require 'win32ole'
> > >
> > > ie = WIN32OLE.new('InternetExplorer.Application')
> > >
> > > .
> > > .
> > > .
> > > insert code to display a web page here...
> > > .
> > > .
> > > .
> > >
> > > elements = ie.document.all
> > > elements.each do |element|
> > > ev = WIN32OLE_EVENT.new(element, 'HTMLElementEvents2')
> > > .
> > > .
> > > .
> > > assign event handlers here
> > > .
> > > .
> > > .
> > > end
> > >
> > > ---------------- (snip) -----------------------
> > >
> > > And here's the URL for the Microsoft documentation that makes the claims
> > > about the HTMLElementEvents2 interface:
> > > http://msdn.microsoft.com/workshop/browser/mshtml/tutorial...
> > >
> > > What am I missing? Do I have to somehow massage the element into a
> > > different object that will handle the HTMLElementEvents2 interface? Or
> > > should I be using another interface entirely? (BTW, is there any way in
> > > WIN32OLE to figure out which interfaces an object supports?)
> > >
> > > Any help will be much appreciated!
> > >
> > > Will Gwaltney
> > > SAS Institute

Will Gwaltney

10/8/2004 12:12:00 PM

0

Hi Paul,

Funny you should ask! I'm doing pretty much the same thing you're
planning to do. I'm hoping to get permission to open-source my code in the
next week or so; I'll drop you a line when I do. The script recorder
certainly won't be finished then, but any help anyone wanted to give would
be most appreciated.

BTW, I think I've come up with a way to figure these interfaces out.
Unfortunately, it doesn't involve ruby. :-( I'm going to put together an
HTML page with all the controls I care about, then run it through a python
program that will output all the connection points for those controls. Then
I'll use the discovered interfaces in the ruby-based script recorder.
Python's COM support includes low-level stuff like QueryInterface that I
haven't been able to figure out with WIN32OLE. Any port in a storm, I
guess... :-)

Will

"Paul" <paul.rogers@shaw.ca> wrote in message
news:4ee21163.0410071902.7c89b437@posting.google.com...
> Will, can I ask what you aredoing with these interfaces? Im working on
> a new version of some code that we use to test web applications via
> IEs OLE interface and DOM.
> One of the things Im hoping to do is a script recorder, and these
> events would be essential in letting me recoed a users actions
>
> Thanks
>
> Paul
>
>
> "Will Gwaltney" <will.gwaltney@sas.com> wrote in message
news:<ck3ku6$m36$1@license1.unx.sas.com>...
> > Thanks for the reply, Graham. As near as I can tell, the page you
mention
> > on the Microsoft site has *most* of the interfaces, but not all of them
> > (thanks, Microsoft...) I couldn't figure out which interfaces to use
for
> > submit and reset buttons and a few others. So one of the things I've
been
> > trying to figure out is how to get Ruby to tell me which interfaces a
> > particular element supports. I know the
> > IConnectionPointContainer::EnumConnectionPoints method in C++ will get
me
> > that info, but I don't know how to call it from WIN32OLE. Things are
> > getting desperate; I might have to resort to using VB! :-)
> >
> > Will
> >
> > "Graham Jenkins" <gjenkins@xchanging.com> wrote in message
> > news:e249d8e7.0410070419.113506fc@posting.google.com...
> > > The HTMLElementEvents2 interface appears to be supported by
> > > "non-functional" elements such as SPAN, DIV, P. See
> > >
> >
http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/mshtml/reference/events/...
> > > for other interfaces - such as HTMLAnchorEvents.
> > >
> > > ie.document.all.each { |element|
> > > if element.tagName == 'A'
> > > ev = WIN32OLE_EVENT.new(element, 'HTMLAnchorEvents')
> > > ev.on_event {|*args|
> > > p args
> > > }
> > > end
> > > }
> > >
> > > "Will Gwaltney" <will.gwaltney@sas.com> wrote in message
> > news:<ck13hq$fog$1@license1.unx.sas.com>...
> > > > I'm using WIN32OLE_EVENT to set up some event handlers on various
DHTML
> > > > elements in Internet Explorer, and I'm having a bit of trouble
> > identifying
> > > > the right event dispinterfaces to use. The Microsoft online
> > documentation
> > > > is less than helpful; they claim that you can use the
HTMLElementEvents2
> > > > interface on most all the HTML elements you care about, but I'm
getting
> > the
> > > > following when I try:
> > > >
> > > > interface not found
> > > > HRESULT error code:0x80004002
> > > > No such interface supported
> > > >
> > > > Here's a code skeleton that outlines what I'm trying to do:
> > > >
> > > > ---------------- (snip) -----------------------
> > > >
> > > > require 'win32ole'
> > > >
> > > > ie = WIN32OLE.new('InternetExplorer.Application')
> > > >
> > > > .
> > > > .
> > > > .
> > > > insert code to display a web page here...
> > > > .
> > > > .
> > > > .
> > > >
> > > > elements = ie.document.all
> > > > elements.each do |element|
> > > > ev = WIN32OLE_EVENT.new(element, 'HTMLElementEvents2')
> > > > .
> > > > .
> > > > .
> > > > assign event handlers here
> > > > .
> > > > .
> > > > .
> > > > end
> > > >
> > > > ---------------- (snip) -----------------------
> > > >
> > > > And here's the URL for the Microsoft documentation that makes the
claims
> > > > about the HTMLElementEvents2 interface:
> > > > http://msdn.microsoft.com/workshop/browser/mshtml/tutorial...
> > > >
> > > > What am I missing? Do I have to somehow massage the element into a
> > > > different object that will handle the HTMLElementEvents2 interface?
Or
> > > > should I be using another interface entirely? (BTW, is there any
way in
> > > > WIN32OLE to figure out which interfaces an object supports?)
> > > >
> > > > Any help will be much appreciated!
> > > >
> > > > Will Gwaltney
> > > > SAS Institute