Monitoring running Windows Applications

Matt Gerrans mgerrans at ix.netcom.com
Sat Dec 8 03:23:14 EST 2001


The Python Windows modules don't seem to include ToolHelp API, which you need
to enumerate processes (CreateToolhelp32Snapshot(), Process32First() and
Process32Next()).

However they do include EnumWindows() in the win32gui module.   That may be
sufficient for your needs; it will allow you to enumerate all top-level
windows.   win32gui also includes EnumChildWindows() if you want to delve
deeper.   That would, for instance, allow you to look at (among the plethora
of other child windows) all the documents being edited in a MDI application
like Excel.   This assumes the document window titles include the document
title, which they usually do.

Of course, if you really want to get a process list, you need to use the
ToolHelp API.  You can write a Python extension, or better yet, write a COM
Automation server that does what you want and use win32com.client.Dispatch to
easily connect to it.   In fact, I like this idea and may do it myself...

- Matt

(Five Fresh) Fish <root at 127.0.0.1> wrote in message
news:3c13b5b2.56161165 at 127.0.0.1...
> Here is, I think, a stumper:
>
> How can one get Python to identify either the applications that are
> currently running in Windows, in real-time (ie. as an application
> monitor)...
>
> Or, better, how can one get Python to identify all the open windows, in
> real-time?
>
> [The idea being that if one can do this, it'd be a breeze to create a tool
> that can keep an automatic diary of one's work tasks during the day...]





More information about the Python-list mailing list