Re: VBScript/COM DCOM settings

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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.
.



Relevant Pages

  • Re: Firefox 4 reversed Open in a new window, and Open in a new tab
    ... Although I started 3 new windows instead of tabs before I figured out ... problem I had with "Start new window" is that it turns out, ... A newer version of Firefox, will use information from the older ... For example, if I look for sqlite (a database type), I find the program ...
    (microsoft.public.windowsxp.general)
  • Re: Maybe Safari 4 actually is for Windows
    ... Putting the tabs above all the other window content is conceptually ... It makes sense to put the address bar ... own controls part of a tab, ...
    (comp.sys.mac.advocacy)
  • Re: Safari 4 labled a "disaster"
    ... "This is where it goes wrong for Safari 4. ... There, the tabs are the titlebar, ... have to be able to drag the window via this new tabtitlebar widget, Apple ... tabs themselves the place to drag the window. ...
    (comp.sys.mac.advocacy)
  • Re: Safari 4 labled a "disaster"
    ... "This is where it goes wrong for Safari 4. ... There, the tabs are the titlebar, ... a tab bar, and consequently, does neither of the two very well. ... tabs themselves the place to drag the window. ...
    (comp.sys.mac.advocacy)
  • Explorer weirdness
    ... I have a whole shopping list here of Windows Explorer oddities. ... Closing an open Explorer window ... - Select several files to move, drag them to another folder (window ...
    (microsoft.public.windowsxp.general)