Kill process based on window name (win32)

Roger Upole rupole at hotmail.com
Sat Aug 12 02:08:21 EDT 2006


drodrig wrote:
> Hi.
>
> I am trying to close/kill all processes that show visible windows on
> Windows XP. So far I've created a script that uses win32gui.EnumWindows
> to iterate through all windows, check for which windows are visible,
> then send a WM_CLOSE message to the window to request that it closes.
> Of course, not all apps want to close nicely. At this point I need to
> use something like TerminateProcess to kill the app, but how do I find
> the process id (hopefully based on the window id).
>
> Thanks for any help.
>

win32process.GetWindowThreadProcessId should do the trick.

       Roger





More information about the Python-list mailing list