Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
inet
active_desktop
active_scrptng
asp.components
asp.db
asp.general
comctl32
comp.packaging
components.dev
dbweb
dhtml_editing
docobjects
html_authoring
html_objmodel
iis
iis.ftp
iis.security
iis.smtp_nntp
indexserver
misc
mshtml_hosting
scripting.jscript
scripting.vbscript
sdk_setup
shell_objmodel
urlmonikers
webbrowser_ctl
wininet
  
 
date: Tue, 4 Apr 2006 14:00:03 -0700,    group: microsoft.public.inetsdk.programming.html_objmodel        back       


HOWTO Get an IHTMLElement object from IAccessible   
HOWTO Get an IHTMLElement object from IAccessible

Please help,

I'm trying to make a kind of Spy++ app. I want to get the value of HTML 
elements in Internet Explorer from my app. I have found that I can use 
AccessibleObjectFromPoint to get the IAccessible object (or IDispatch). How 
can I use that to get the object's IHTMLElement interface?
date: Tue, 4 Apr 2006 14:00:03 -0700   author:   ATS

Re: HOWTO Get an IHTMLElement object from IAccessible   
Hi,

I think this article on MSDN will show you how to do exactly what you want. 
The bit you want is near the end of the page.
http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/accessibility/overview/overview.asp

Bill

"ATS"  wrote in message 
news:83EAA7A0-7B21-4093-948E-35ECD2BC6452@microsoft.com...
> HOWTO Get an IHTMLElement object from IAccessible
>
> Please help,
>
> I'm trying to make a kind of Spy++ app. I want to get the value of HTML
> elements in Internet Explorer from my app. I have found that I can use
> AccessibleObjectFromPoint to get the IAccessible object (or IDispatch). 
> How
> can I use that to get the object's IHTMLElement interface?
date: Thu, 20 Apr 2006 11:52:36 -0500   author:   Aberro-Bill am

Re: HOWTO Get an IHTMLElement object from IAccessible   
Thanks for the reply, I found almost all I needed and had managed to make a 
Spy program from IAccessible. The trick was knowing that IAccessible leads to 
an IHTMLWindow or IHTMLElement object (one or the other).

But! I did not find a way to capture the currently selected text. With 
windows, I would use EM_GETSELTEXT or some derivation there of to get the 
currently selected text for NON-Rech Edit controls, and WM_COPY for Rich Edit 
controls. 

But with IAccessible, I could not find a simple solution. First I tried 
IAccessible's get_accSelect, but it  does not capture the selected text. So I 
tried to use IAccessible to get the DOM from an IHTMLElement/IHTMLWindow, and 
to my surprise, the DOM (MSHTML) does not seem to have a "GetFocus" function 
to let one get the element with the focus, or anything to issue an equivalent 
of EM_GETSELTEXT or WM_COPY.

Any ideas? I'd really like to just somehow issue a WM_COPY equivalent on a 
given IAccessible object or the DOM.
date: Thu, 20 Apr 2006 10:09:02 -0700   author:   ATS

Re: HOWTO Get an IHTMLElement object from IAccessible   
I think I can get you part way there.
On the Accessibility side you can call get_accFocus() to find out which 
element has keyboard focus.
On the DOM side you can find out which element has focus by calling 
IHTMLDocument2.activeElement()
You can get to a document object to make this call from your Accessible 
object starting point by getting the HTMLElement from the Accessible Object, 
then getting the document from the HTMLElement.

As to getting or setting just the selected text, or controlling the text 
selection - I can't help you with that.

Bill

"ATS"  wrote in message 
news:12D96A45-7A3C-4E77-8C18-0DD7877015D6@microsoft.com...
> Thanks for the reply, I found almost all I needed and had managed to make 
> a
> Spy program from IAccessible. The trick was knowing that IAccessible leads 
> to
> an IHTMLWindow or IHTMLElement object (one or the other).
>
> But! I did not find a way to capture the currently selected text. With
> windows, I would use EM_GETSELTEXT or some derivation there of to get the
> currently selected text for NON-Rech Edit controls, and WM_COPY for Rich 
> Edit
> controls.
>
> But with IAccessible, I could not find a simple solution. First I tried
> IAccessible's get_accSelect, but it  does not capture the selected text. 
> So I
> tried to use IAccessible to get the DOM from an IHTMLElement/IHTMLWindow, 
> and
> to my surprise, the DOM (MSHTML) does not seem to have a "GetFocus" 
> function
> to let one get the element with the focus, or anything to issue an 
> equivalent
> of EM_GETSELTEXT or WM_COPY.
>
> Any ideas? I'd really like to just somehow issue a WM_COPY equivalent on a
> given IAccessible object or the DOM.
>
>
>
date: Thu, 20 Apr 2006 12:31:16 -0500   author:   Aberro-Bill am

Re: HOWTO Get an IHTMLElement object from IAccessible   
Thanks, I found the activeElement too, and it is good to know that it and 
get_accFocus are the way to go. But the trick is to issue a WM_COPY 
equivalent. I'm trying to use "oncopy", but this is not working. It requires 
using pIHTMLDocument4->createEventObject to create an event, and then issuing 
something like:

pIHTMLElement3->fireEvent(_bstr_t("oncopy"), &VARIANT_Temp, 
&VARIANT_BOOL_Temp)

But the event is not working.

Any ideas?
date: Thu, 20 Apr 2006 10:46:02 -0700   author:   ATS

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us