 |
|
|
|
| Author |
Message |
RLoski
Joined: 14 Jan 2008 Posts: 2
|
Posted: Mon Jan 14, 2008 2:26 pm Post subject: Getting to document dom from hwnd of IE window |
|
|
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 |
|
 |
Larry Serflaten
Joined: 04 Oct 2007 Posts: 2644
|
Posted: Mon Jan 14, 2008 8:36 pm Post subject: Re: Getting to document dom from hwnd of IE window |
|
|
"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 |
|
 |
Steve Easton
Joined: 04 Oct 2007 Posts: 456
|
Posted: Mon Jan 14, 2008 9:57 pm Post subject: Re: Getting to document dom from hwnd of IE window |
|
|
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 |
|
 |
RLoski
Joined: 14 Jan 2008 Posts: 2
|
Posted: Tue Jan 15, 2008 7:20 am Post subject: Re: Getting to document dom from hwnd of IE window |
|
|
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 |
|
 |
mayayana
Joined: 04 Oct 2007 Posts: 734
|
Posted: Tue Jan 15, 2008 2:27 pm Post subject: Re: Getting to document dom from hwnd of IE window |
|
|
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 |
|
 |
Kevin Provance
Joined: 04 Oct 2007 Posts: 800
|
Posted: Fri Feb 01, 2008 2:13 pm Post subject: Re: Getting to document dom from hwnd of IE window |
|
|
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 |
|
 |
mayayana
Joined: 04 Oct 2007 Posts: 734
|
Posted: Fri Feb 01, 2008 3:01 pm Post subject: Re: Getting to document dom from hwnd of IE window |
|
|
> 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 |
|
 |
|
|
| 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 |
|
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
|