Ok I figured out how to do it: Here's the code I made mostly from copying the examples. If anyone could tell me how the code works, that would still be appriciated, for example why/how do I need this function _MyCallback?
-Greg My code: import sys import win32process, win32api, win32pdhutil, win32con, win32security import win32event, msvcrt, win32gui def get_all_windows(): """Returns dict with window desc and hwnd, don't ask me how it works!""" def _MyCallback( hwnd, extra ): """Helper function for above??""" hwnds, classes = extra hwnds.append(hwnd) classes[win32gui.GetClassName(hwnd)] = hwnd windows = [] classes = {} win32gui.EnumWindows(_MyCallback, (windows, classes)) return classes def request_windows_to_close(list_window_descs_to_close): """Send me a list of stuff to close such as: stuff_to_close=['OP15_OmniPage_Agent_Class',]""" classes=get_all_windows() for windesc_to_close in list_window_descs_to_close: if classes.has_key(windesc_to_close): win32gui.PostMessage(classes[windesc_to_close], win32con.WM_CLOSE, 0, 0) print 'requested closure with', windesc_to_close else: print 'Did not find a window desc. as',windesc_to_close _______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32