[python-win32] monitoring application controls...

Tim Roberts timr at probo.com
Mon Nov 14 19:13:38 CET 2005

On Sat, 12 Nov 2005 12:40:03 -0700, "Brian Jarrett" 
<bjarrett at garcoschools.org> wrote:

>I'm currently researching ways to use Python to monitor the state, data,
>and events associated with controls (comboboxes, editboxes, etc.) using
>Python and the win32 extensions.  I'd like to write a script that would
>allow me to observe the changes that occur to an application's controls
>while I use the application.  For example, logging the text that gets
>entered in a combo box to a text file.
>I've already found the necessary information for enumerating windows and
>their controls, mostly by looking at the winguiauto.py example.
>I guess I'm used to working with OnChange and OnClick events when
>writing an application, but now I want to be able to "hook" into these
>sort of events when outside of the application itself.
>Where should I be looking?  Any help would be appreciated.

Well, I started to reply that I believed this could not be done entirely 
in Python, but I thought I'd better do a quick web search first, and it 
appears I am wrong.

What you need are Windows hooks, which allows you to participate in the 
window procedures for other processes.  Implementing a hook requires 
code in a DLL, because the DLL has to actually be "injected" into 
another process, to run in that processes context.  That would usually 
make Python unsuitable, but there are people doing research in 
accessability that have done it:


Note particularly the libraries for pyHook and pyAA.

Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.

More information about the Python-win32 mailing list