[python-win32] win32api.FindWindow returns 0 sometimes

Elias Fotinis efotinis at yahoo.com
Sat Sep 5 13:06:23 CEST 2009


Running Vista x64, PythonWin 2.6.1 x64, pywin32 214 x64.

win32api.FindWindow sometimes returns 0 instead of raising an exception. I 
suppose that's a bug and will submit it if so. Can anyone verify? I tried 
peeking into the code, but I have no clue about SWIG.  :o)

Example code:
    import win32api
    import subprocess

    subprocess.Popen('notepad')
    while True:
        try:
            w = win32gui.FindWindow('Notepad', None)
            print w
            if w:
                break
        except win32gui.error:
            print 'not found'

Sometimes it works as expected:
    not found
    not found
    not found
    10684490

but sometimes it produces this:
    not found
    not found
    not found
    0
    0
    2623920




More information about the python-win32 mailing list