[python-win32] Wait for a window with a specified title

Tim Roberts timr at probo.com
Mon May 28 00:11:25 EDT 2018


On May 27, 2018, at 6:36 AM, Ram Rachum <ram at rachum.com> wrote:
> 
> I'd like to use the `wmi` module to detect when a window with the title "Foo Bar" was created, and then kill the process that created this window. Is this possible?

Not with WMI, no.


> (I can do the killing without `wmi`, I just need to ID the process.)
> 
> Note that I don't want to be periodically polling for that window, I want to be listening to an event so there wouldn't be a big delay.

I don't know how much overhead you are willing to impose, but you can always install a WH_CALLWNDPROC window hook and look for WM_CREATE messages.  That injects a DLL into every process in the system, so I'm not convinced it can be done with Python.  You may need to write a C++ DLL and have it communicate with your Python process.
— 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the python-win32 mailing list