[python-win32] win32api.FindWindow returns 0 sometimes

2009-09-05 Thread Elias Fotinis

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


___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] win32api.FindWindow returns 0 sometimes

2009-09-05 Thread Michel Claveau

Hi!

Try to put a 
   time.sleep(0.001)

inside the  while, for give some time to work to Windows...

@+
--
Michel Claveau 


___
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32