[python-win32] Query and remove all IEBrowsers

George Flaherty George.Flaherty at sas.com
Thu Jan 5 22:35:42 CET 2006


Humm sorry guys let me be a bit more clear, I tried to run the this code, but it doesn't close the window
Thanks
-george


import win32gui
import win32con
import string

def windowEnumerationHandler(hwnd, resultList):
    
    if string.find(win32gui.GetWindowText(hwnd),"Microsoft Internet Explorer") != -1:
        resultList.append(hwnd)
    else:
        None
        
if __name__ == '__main__':  
    topWindows = []
    win32gui.EnumWindows(windowEnumerationHandler, topWindows)    
    
    for i in topWindows:
        print 'Trying to close IE window = ' + win32gui.GetWindowText(i)
        win32gui.SendMessage(i,win32con.WM_CLOSE,0,0)
         



-----Original Message-----
From: python-win32-bounces at python.org [mailto:python-win32-bounces at python.org] On Behalf Of George Flaherty
Sent: Thursday, January 05, 2006 4:15 PM
Cc: python-win32 at python.org
Subject: Re: [python-win32] Query and remove all IEBrowsers

Okay I figured out all the ides of all the IE Browser windows (thanks), but now how do I send the "WM_CLOSE" to each id?

thanks
george 


-----Original Message-----
From: Niki Spahiev [mailto:niki at vintech.bg]
Sent: Thursday, January 05, 2006 12:46 PM
To: George Flaherty
Cc: python-win32 at python.org
Subject: Re: [python-win32] Query and remove all IEBrowsers

George Flaherty wrote:

> Is it possible with python/win32 to "query and remove" all running internet explorers (ie browsers)?
> 
> I have an automation package that requires no existing internet explorers to be running. So I would like to call a python/win32 script to close out any ie browser windows, then run the automation tools.

You can enumerate top level windows and send WM_CLOSE to IE ones.

Niki Spahiev
_______________________________________________
Python-win32 mailing list
Python-win32 at python.org
http://mail.python.org/mailman/listinfo/python-win32


More information about the Python-win32 mailing list