msvisual.com Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Getting to document dom from hwnd of IE window

 
Post new topic   Reply to topic    msvisual.com Forum Index -> VB WinAPI
Author Message
RLoski



Joined: 14 Jan 2008
Posts: 2

PostPosted: Mon Jan 14, 2008 2:26 pm    Post subject: Getting to document dom from hwnd of IE window Reply with quote

I can get the hwnd for the IE window. I am assuming that a particular page
is displayed in that IE window and I want to call a javascript routine that
is defined on that page. How would I do this?

This is not my architecture.


Current version of IE: 6, OS: Windows XP.
--
Russel Loski, MCSD.Net

Archived from group: microsoft>public>vb>winapi
Back to top
View user's profile Send private message
Larry Serflaten



Joined: 04 Oct 2007
Posts: 2644

PostPosted: Mon Jan 14, 2008 8:36 pm    Post subject: Re: Getting to document dom from hwnd of IE window Reply with quote

"RLoski" wrote
> I can get the hwnd for the IE window. I am assuming that a particular page
> is displayed in that IE window and I want to call a javascript routine that
> is defined on that page. How would I do this?

I've never tried that before, but to help point the way, I'll suggest two things,

1. Get an object reference to the IE window:

Function IERef(Find_hWnd As Long) As InternetExplorer
' REFERENCE Microsoft Internet Controls for:
Dim SW As ShellWindows
Dim IE As InternetExplorer

Set SW = New ShellWindows

For Each IE In SW
If TypeName(IE.Document) = "HTMLDocument" Then
If IE.hWnd = Find_hWnd Then
Set IERef = IE
Exit Function
End If
Next
End Function


2. Use the DOM ( Document.parentWindow.execScript) to call your script.

LFS
Back to top
View user's profile Send private message
Steve Easton



Joined: 04 Oct 2007
Posts: 456

PostPosted: Mon Jan 14, 2008 9:57 pm    Post subject: Re: Getting to document dom from hwnd of IE window Reply with quote

However, with IE 7 and tabbed windows, one hwnd can have several pages.
The user will have to check each hwnd
for each LocationName and / or LocationURL
to ensure he has the correct page.


--

Steve Easton



"Larry Serflaten" wrote in message @TK2MSFTNGP06.phx.gbl...
>
> "RLoski" wrote
>> I can get the hwnd for the IE window. I am assuming that a particular page
>> is displayed in that IE window and I want to call a javascript routine that
>> is defined on that page. How would I do this?
>
> I've never tried that before, but to help point the way, I'll suggest two things,
>
> 1. Get an object reference to the IE window:
>
> Function IERef(Find_hWnd As Long) As InternetExplorer
> ' REFERENCE Microsoft Internet Controls for:
> Dim SW As ShellWindows
> Dim IE As InternetExplorer
>
> Set SW = New ShellWindows
>
> For Each IE In SW
> If TypeName(IE.Document) = "HTMLDocument" Then
> If IE.hWnd = Find_hWnd Then
> Set IERef = IE
> Exit Function
> End If
> Next
> End Function
>
>
> 2. Use the DOM ( Document.parentWindow.execScript) to call your script.
>
> LFS
>
>
Back to top
View user's profile Send private message
RLoski



Joined: 14 Jan 2008
Posts: 2

PostPosted: Tue Jan 15, 2008 7:20 am    Post subject: Re: Getting to document dom from hwnd of IE window Reply with quote

Thank you for your point. I will make sure to alert my client about this.


--
Russel Loski, MCSD.Net


"Steve Easton" wrote:

> However, with IE 7 and tabbed windows, one hwnd can have several pages.
> The user will have to check each hwnd
> for each LocationName and / or LocationURL
> to ensure he has the correct page.
>
>
> --
>
> Steve Easton
>
>
>
Back to top
View user's profile Send private message
mayayana



Joined: 04 Oct 2007
Posts: 734

PostPosted: Tue Jan 15, 2008 2:27 pm    Post subject: Re: Getting to document dom from hwnd of IE window Reply with quote

If you run into any problems, you might find this helpful
(in addition to Spy++) -

www.jsware.net/jsware/vbcode.php3#shlop

The download is sample code and lots of notes
about accessing Document objects and ShellFolderView
objects from folder windows, Document objects
from HTAs, etc. Basically, you can get hold of a
Document from any window of class:

"Internet Explorer_Server"

But in some cases it might be necessary to walk
a process "window tree" to sort them out.

> Thank you for your point. I will make sure to alert my client about this.
>
>
> --
> Russel Loski, MCSD.Net
>
>
> "Steve Easton" wrote:
>
> > However, with IE 7 and tabbed windows, one hwnd can have several pages.
> > The user will have to check each hwnd
> > for each LocationName and / or LocationURL
> > to ensure he has the correct page.
> >
> >
> > --
> >
> > Steve Easton
> >
> >
> >
>
Back to top
View user's profile Send private message
Kevin Provance



Joined: 04 Oct 2007
Posts: 800

PostPosted: Fri Feb 01, 2008 2:13 pm    Post subject: Re: Getting to document dom from hwnd of IE window Reply with quote

Perhaps this: http://support.microsoft.com/kb/249232?

How to get IHTMLDocument2 from a HWND

"RLoski" wrote in message @microsoft.com...
|I can get the hwnd for the IE window. I am assuming that a particular page
| is displayed in that IE window and I want to call a javascript routine
that
| is defined on that page. How would I do this?
|
| This is not my architecture.
|
|
| Current version of IE: 6, OS: Windows XP.
| --
| Russel Loski, MCSD.Net
Back to top
View user's profile Send private message
mayayana



Joined: 04 Oct 2007
Posts: 734

PostPosted: Fri Feb 01, 2008 3:01 pm    Post subject: Re: Getting to document dom from hwnd of IE window Reply with quote

> Perhaps this: http://support.microsoft.com/kb/249232?
>
> How to get IHTMLDocument2 from a HWND
>
The OP probably wouldn't need that, but in any case,
the VB version is included and explained in the code
I already linked to.

Back to top
View user's profile Send private message
Display posts from previous:   
Related Topics:
Window Location From Hwnd I need to locate a windows top right hand corner, which I have shelled, so I can add a custom controll to it. Is it possible to retrieve the x\y co-ordinates from a HWND? I have full controll over the new application. I shell it or bring it to the top and

How to close a window base on hwnd Hi, I need to close a internet explorer window based on hwnd given. I used endtask to do this, but sometimes when I endtask a IE window, the rest of the window also close. May I know is there any other API that I can use to close a window without affectin

Given Window hWnd and Control ID, how to find Control's Pare Given the hWnd of an application Window and the control ID of a control within that window, how can I find the control's direct parent? You might be tempted to say 'dude - you've already got the hWnd - use it!' but this doesn't always work. I've got a For

Get Hwnd Hi, Im making a control program for another program and im using sendmessage api to set text to text boxes and sendmessage api to push buttons.. My problem is i need the indevidual hwnd's of two textboxes that have the same class, same parrent, and i can

hwnd I saw a lot of examples to get hwnd with me.hwnd but in vb.net there seems to be no property in windows.forms called hwnd. How can I get hwnd in vb.net? Thanks
Post new topic   Reply to topic    msvisual.com Forum Index -> VB WinAPI All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group