[python-win32] Creating a process and getting a handle

Alec Bennett whatyoulookin at yahoo.com
Wed Jan 23 08:26:50 CET 2008


Please post what you find on this, I'm curious too.

If you do go the enum windows route, It thought I'd
post my notes on this since I recently got it working.
It's somewhat confusing (for me at least) since it
uses a callback:


# Callback function for findWindowHandle
def windowEnumerationHandler(hwnd, resultList):

    resultList.append((hwnd,
win32gui.GetWindowText(hwnd)))


def findWindowHandle(string):

    topWindows = []

    win32gui.EnumWindows(windowEnumerationHandler,
topWindows)

    for window in topWindows:
        if string in window[1]: return window[0],
window[1]

    # Looks like we didn't find anything
    return None, None


handle, windowtext = findWindowHandle("Notepad")







      ____________________________________________________________________________________
Never miss a thing.  Make Yahoo your home page. 
http://www.yahoo.com/r/hs


More information about the python-win32 mailing list