Howto get process id from window handler (windows)

Colin Brown cbrown at metservice.com
Thu May 23 01:01:40 EDT 2002


"Miki Tebeka" <tebeka at cs.bgu.ac.il> wrote in message
news:33803989.0205210027.65b5c7ec at posting.google.com...
> Hello All,
>
> I'd like to find a application by name and then terminate it.
> EnumWindows gives my the window handle of all current windows, however
> TerminateProcess needs a process handle.
>
> How can I make the link? (hWnd -> hInstance)
>
> Thanks.
> Miki

Hi Miki

A solution I have been using for doing under-the-hood windows management is
to call various "pstools" utilities ( www.sysinternals.com ) with
os.system(). "pskill" will kill processes by name or pid.

os.system(r'c:\pstools\pskill your_process > nul')

Colin Brown
PyNZ






More information about the Python-list mailing list