Enumerating IE instances

topic: 

The Windows Shell

provides a powerful set of automation objects that enable you to access the file system, launch programs, and change system settings.

The Shell Windows Method

creates and returns a ShellWindows object that represents a collection of all of the open windows that belong to the Shell, including Internet Explorer.

$SAMPLECODE$

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16

oShell = CREATEOBJECT("Shell.Application")
* A collection of the open windows that belong to the Shell 
oShellWindows = oShell.Windows
FOR EACH oIE IN oShellWindows 
	IF "IEXPLORE.EXE" == JUSTFNAME(UPPER(oIE.FullName))
		? oIE.LocationName
		? oIE.LocationURL
		?
	ENDIF
ENDFOR 
oShellWindows = NULL
oShell = NULL


Comments

Congratulations Sergey!
I have a little observation. In my computer I got the error "OLE error code 0x80020006: Unknow name" because Outlook's window have no FullName property. I think that "IF" below solve the problem:
1
2
	IF TYPE("oIE.FullName") == [C] AND "IEXPLORE.EXE" == JUSTFNAME(UPPER(oIE.FullName))

I hope this helps.

Hi Erick,

Thanks for letting me know. I run the code on PCs with Outlook 2003 and 2007 and neither showed up in the Shell windows list. Anyway, your code will fix the problem you described.

Hi Sergey,

I run the code on PC with Win XP and Outlook 2002 and the error (talked previously) occur. If I ignore the error, the result for booth commands "? oIE.LocationName" and "? oIE.LocationURL" is "outlook:Caixa%20de%20entrada". The command "? oIE.hWnd" returns "Unknow name" too. Anyway, the code that I suggested fix the problem.
Thanks for the comment!