[python-win32] Re: How to get the main window handle of an
application started with win32process.CreateProcess() ?
Roel Schroeven
rschroev_nospam_ml at fastmail.fm
Wed Mar 23 20:11:38 CET 2005
Pierre Rouleau wrote:
> Hi all,
>
> I am trying to send a WM_CLOSE mesage to the main window of a Win32
> GUI application I started with win32process.CreateProcess(). I want to
> terminate the application gracefully, allowing the application to
> perform all of its regular cleanup and prompting it normally does when
> the user requests to close it.
>
> For that reason, I do not want to use win32process.TerminateProcess().
>
> Since I started the application with win32process.CreateProcess() I have
> the process information. But to use win32gui.PostMessage() to the
> application main window I must find the main window handle of that
> application.
>
> Does anyone know how to do this?
You could enumerate the windows with win32gui.EnumWindows and filter
those belonging to that process using win32process.GetWindowThreadProcesId.
--
If I have been able to see further, it was only because I stood
on the shoulders of giants. -- Isaac Newton
Roel Schroeven
More information about the Python-win32
mailing list