scott nelson qwhsclzgmailcom greets im looking use win32api win32gui modules bit windows tinkering win2k activestates python 241 distribution ive hit snag id like processwindow steal focus whatever window currently get bit input keyboard restore focus back original window simple cases win32guisetforegroundwindowhwnd seems im looking works fine simply try set focus another window app im seeing unexpected behavior go beyond wrote simple test script enumerates visible windows tries give one focus turn short delay gets 12 windows 810 nonminimized windows open ie notepad wordpad etc gives traceback recent call last file d_codepythonappswintestspy line 25 cycle_foreground file d_codepythonappswintestspy line 20 cycle_foreground win32guisetforegroundwindowhandle pywintypeserror 0 setforegroundwindow error message available wrong case bad assumptions app allowed give away focus cant force different apps window focus give away focus way accomplish ive attempted using mix setfocus bringwindowtotop enablewindow couldnt find magic combo ive attached test script run wintests cycle attempt cycle focus top level windows see traceback run wintests 12345 successfully set focus window hwnd 12345 run wintests get list top level window names hwnds ive tried reading win32 docs provided activestates pythonwin ive read bit win32 api msdn ive googled around bit havent found much got curious tried code something similar c uses identical api calls tell seems problem cycling toplevel windows ive attached cpp file well discrepancy im seeing win32gui c thoughts scott wed 06 aug 2008 065153 0500 pythonwin32 confusion setforegroundwindow