I'm trying to loop through the existing Shell windows in order to get an object reference to a particular browser window. Unfortunately, the Shell Window collection includes IE windows, Windows Explorer Windows and perhaps some other variants. What I am trying to find is a window object property I can test to see if the window is an IE window. If it is then I'll check other properties for a match - like o_window.document.title. If the window is NOT an IE window, then the document property doesn't exist and my application fails. I've been using the .path property and find that it works most of the time (it points to program files\Internet Explorer\" when it is IE) but I have found that some Shell instances don't support that property either. It sure seems there should be a simple test... any ideas? Thanks, Dale Set o_Shell = CreateObject("Shell.Application") Set o_ShellWindows = o_Shell.Windows () For each o_window In o_ShellWindows ' What property can I test to see if this is an IE Window? Next
DaleH wrote: > I'm trying to loop through the existing Shell windows in order to get > an object reference to a particular browser window. Unfortunately, > the Shell Window collection includes IE windows, Windows Explorer > Windows and perhaps some other variants. > > What I am trying to find is a window object property I can test to > see if the window is an IE window. If it is then I'll check other > properties for a match - like o_window.document.title. If the window > is NOT an IE window, then the document property doesn't exist and my > application fails. I've been using the .path property and find that > it works most of the time (it points to program files\Internet > Explorer\" when it is IE) but I have found that some Shell instances > don't support that property either. > > It sure seems there should be a simple test... any ideas? Run this with both IE and Windows Explorer windows open... Set o_Shell = CreateObject("Shell.Application") Set o_ShellWindows = o_Shell.Windows () For each o_window In o_ShellWindows wscript.echo TypeName(o_window.document) Next -- Michael Harris Microsoft MVP Scripting
Thanks Michael. That works. Unfortunately, where I'm actually trying to apply this is in a scripting language called AutoIt -- which support COM but does not (yet) have a TypeName function.The AutoIt devs are looking to supply a TypeName function, but in the mean time it seemed so logical that there would be a Shell property that held this information. If you can think of any other tricks, I'd love to hear them. Thanks very much for the reply. Dale "Michael Harris (MVP)" wrote: > DaleH wrote: > > I'm trying to loop through the existing Shell windows in order to get > > an object reference to a particular browser window. Unfortunately, > > the Shell Window collection includes IE windows, Windows Explorer > > Windows and perhaps some other variants. > > > > What I am trying to find is a window object property I can test to > > see if the window is an IE window. If it is then I'll check other > > properties for a match - like o_window.document.title. If the window > > is NOT an IE window, then the document property doesn't exist and my > > application fails. I've been using the .path property and find that > > it works most of the time (it points to program files\Internet > > Explorer\" when it is IE) but I have found that some Shell instances > > don't support that property either. > > > > It sure seems there should be a simple test... any ideas? > > Run this with both IE and Windows Explorer windows open... > > Set o_Shell = CreateObject("Shell.Application") > Set o_ShellWindows = o_Shell.Windows () > For each o_window In o_ShellWindows > wscript.echo TypeName(o_window.document) > Next > > > -- > Michael Harris > Microsoft MVP Scripting