Re: VBScript/COM DCOM settings
- From: Csaba Gabor <danswer@xxxxxxxxx>
- Date: Wed, 15 Apr 2009 12:38:26 -0700 (PDT)
I think I have some useful info...
On Apr 12, 3:59 pm, "Alex K. Angelopoulos" <aka(at)mvps.org> wrote:
I've got nothing useful on this, unfortunately. : / I do have some comments
on tabbing, which don't tell us much useful either. Excuse the PowerShell in
data gathering below; it made it much easier to quickly test some things...
"Csaba Gabor" <dans...@xxxxxxxxx> wrote in messagenews:ae245a9f-e36e-4a9f-98f0-cb3fe5525605@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
http://msdn.microsoft.com/en-us/library/aa768329(VS.85).aspx
It says that pDisp, the first argument to DocumentComplete
is either a frame or top level window (of typename
HTMLWindow2 - it doesn't say that part, but that's what it is).
Side topic from this page: What's the distinction between "top level" and
"highest level"? This from the Remarks section puzzles me:
"In the loading process, the highest level frame, which is not necessarily
the top-level frame, fires the final DocumentComplete event."
Intersting. I don't understand their meaning here. I would have
thought that "highest level" should be repleced by "current"
Comments on the tabbed browsing issue below:
In any case, this issue of IE as a tabbed browser is
interesting. I am particularly interested in the
COM/VBScript way of doing the following:
1) Given an IE object, how do you enumerate the
top level windows (ie. the tabs)?
At least I have a way. Not nice, but a way:
Collect the windows (ie. tabs) as they come
through the NavigateComplete or DocumentComplete
event handler.
Shell.Application works fine. There's apparently a "root" IE running, but
even though it shows up on the process list, it will never return a window
object when you enumerate windows using Shell.Application's Windows()
Are you sure that's an IE? On my Win XP Pro when I close down all
instances of IE and Windows Explorer, it still shows me an Explorer
process. When you use Shell.Application's Windows you get both IEs
and Explorers, and which one it is depends on where you navigate it
to.
method. Here's what you see if you check processes with a tabbed browser
running and then switch tabs and check again; the identity of the tab seems
to be swapped:
PS> gps iexplore | sort starttime | ft
id,starttime,mainwindowhandle,mainwindowtitle -autosize
Id StartTime MainWindowHandle MainWindowTitle
-- --------- ---------------- ---------------
4024 2009-04-12 08:58:31 133484 DocumentComplete Event
(InternetExplorer, WebBrowser) - Windows Internet Explorer
3096 2009-04-12 09:00:36 0
4560 2009-04-12 09:38:02 0
PS> gps iexplore | sort starttime | ft
id,starttime,mainwindowhandle,mainwindowtitle -autosize
Id StartTime MainWindowHandle MainWindowTitle
-- --------- ---------------- ---------------
4024 2009-04-12 08:58:31 133484 Google Advanced Search - Windows
Internet Explorer
3096 2009-04-12 09:00:36 0
4560 2009-04-12 09:38:02 0
2) How do I spawn a new tab in a given IE?
I have no idea whether it's possible or not, although it's almost certainly
not controllable through standard COM automation, since that apparent root
IE instance can't be accessed. If I have multiple IE tabs running and start
a new IE instance from script, it shows up as a child of the same IE
instance as the tabs - see this:
OK, here's the way to do it. You need an already extant IE, of
course.
Use the Navigate2 method and for the 2nd argument, pass in 2048,
4096, or 65536. See the documentation here:
http://msdn.microsoft.com/en-us/library/aa752094(VS.85).aspx
http://msdn.microsoft.com/en-us/library/dd565688(VS.85).aspx
PS> $ie = new-object -comobject InternetExplorer.Application
PS> gwmi win32_process | ?{$_.name -eq "iexplore.exe"} | ft
ProcessId,ParentProcessId -AutoSize
ProcessId ParentProcessId
--------- ---------------
4024 2816
3096 4024
4560 4024
4816 4024
However, if I make the window visible, it doesn't show up in the current tab
set. This is probably tied in to security decisions.
3) How do I activate (bring to top) a given tab?
For example, imagine I had titles C, C#, D, D#, E, F...
and I wanted to play a little tune and activate the
corresponding tab in time to the music. Could I
do that?
OK, I don't know the answer to this one (maybe a
focus variant, or AppActivate?), but regarding how to
enumerate the tabs associated with an IE, what you
could do is to hook the NavigateComplete and
DocumentComplete events (noting the associated
IE, of course), and then each time one of them fires
store the window object in an array associated with
the IE object. That way you can iterate throught the
ie object. This is a bit messy because you probably
want to double check that the window (tab) that
caused the event to fire is not already stored on
the array (which you might do by poking a value
and seeing whether it shows up in any of the other
windows - like I say, a bit messy. You could also
get the unique id of each tab's document.body -
that's probably better).
Hmmm, maybe top level window refers to the active
window, whereas highest level window might refere
to a particular tab. But I'm skeptical.
The best tool for this job is always Sendkeys.
PS. In case it wasn't clear, the example under
question 3 was a joke.
Now THAT was funny :)
In case it wasn't clear, so was the answer. :p.
Unfortunately, I don't have a serious answer. It probably IS possible to do
somehow via APIs or even .NET use, and it's quite possible that such a path
will never be blocked since it doesn't have the same risks as direct COM
exposure in this context - but even if that weren't a vague answer, it
wouldn't help much with either WSH or PHP invocation.
- Follow-Ups:
- Re: VBScript/COM DCOM settings
- From: Alex K. Angelopoulos
- Re: VBScript/COM DCOM settings
- References:
- VBScript/COM DCOM settings
- From: Csaba Gabor
- Re: VBScript/COM DCOM settings
- From: Alex K. Angelopoulos
- Re: VBScript/COM DCOM settings
- From: mayayana
- Re: VBScript/COM DCOM settings
- From: Csaba Gabor
- Re: VBScript/COM DCOM settings
- From: Alex K. Angelopoulos
- VBScript/COM DCOM settings
- Prev by Date: searching registry: know the value, don't know the key
- Next by Date: Re: Error copying files
- Previous by thread: Re: VBScript/COM DCOM settings
- Next by thread: Re: VBScript/COM DCOM settings
- Index(es):
Relevant Pages
|