I'm trying to write a Python script where I try to check if any application, besides the current one, is active. If there are any other open windows, I want a pop up question that asks me if I want to close the running applications.
I now found the way to find active processes like this:
import win32gui
def winEnumHandler( hwnd, ctx ):
if win32gui.IsWindowVisible( hwnd ):
print (hex(hwnd), win32gui.GetWindowText( hwnd ))
win32gui.EnumWindows( winEnumHandler, None )
The problem is, this returns only the title names of the active window. But I need the process names to close these windows and somehow I cannot get them.
Does anybody have an idea on how to solve this?
If python process running you can see process named
python.exe
here is a script to terminate desired process by name :