WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Sample code
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Shell Window Details

 Keywords: LocationURL LocationName Url Location Shell Type Window ShellWindows Shell.Application HWND Handle IE MSIE Explorer 




;***************************************************************************
;**
;**  Lists all Shell windows and display details like title, handle and url
;**
;***************************************************************************
url = ""
; The Shell object represents the objects in the Windows Shell.
; http://msdn.microsoft.com/en-us/library/bb776890(VS.85).aspx#roadmap_shell_object
oShellApp = ObjectCreate("Shell.Application")
; Creates and returns a ShellWindows object.
; This object represents a collection of all of the open windows that belong to the Shell.
oWindows = oShellApp.Windows()
; Get total number of Shell windows
cnt = oWindows.Count
url = ""
; Loop once for each shell window
For item = 0 To cnt-1
   ; Get the Window Object
   oWin = oWindows.Item(item);
   ; Get the window handle
   handle = oWin.HWND
   ; Get the URL of the window
   url = oWin.locationURL
   ; Get the name of the window
   name = oWin.locationname
   ; Determine the shell type: Browser or Windows Explorer
   If StrLower(ItemExtract(1,url,':')) == 'file' Then shelltype = 'Windows Explorer'
   Else shelltype = 'Browser'
   ;Display results
   Pause('Shell Window Details','Title: ':name:@CR:'Shell Type: ':shelltype:@CR:'Window Handle: ':handle:@CR:'URL: ':url)
   oWin = 0
Next
;Close open object handles
oWindows = 0
oShellApp = 0
Exit

Article ID:   W18235
Filename:   Shell Window Details.txt
File Created: 2009:08:18:08:45:56
Last Updated: 2009:08:18:08:45:56