win32ui.GetActiveWindow() problem

Michal Bozon bozon at natur.cuni.cz
Mon Mar 13 12:20:22 EST 2000


__Hi__ all.
If you are not Win9x/2000 user, this won't be probably something for you.

I try to make a program for monitoring applicatinons running on my comp
when I'm not at home. My idea is to get active window name in regular
intervals (e.g. 1 minute) and write it to a secret file :-} (The python
script would be runned after Windows startup in Pythonw.exe). I tried
GetActiveWindow function from win32ui (Pythonwin). I wrote something like
following script (maybe not exactly, I have not Python by my hand now)
- - - - -
from win32ui import *
from time import sleep

while 1:   
    s = GetActiveWindow().GetWindowName()
    print s
    sleep(3)
- - - - -
and runned it in Python IDLE.
It was still printing '*Python shell*', but when I activated any other
window, it yielded exception like 'win32ui: No window is active'.
I saved the file and clicked on it (so it was ran directly from
Python.exe) but it raised the same exception, even in beginning. 

What is the exception caused by? Do I use this function correctly?
Or do you have a better idea how to monitor running applications and
documents opened by them... in Win32 environment?

And one additional question. I have already a simple script which is 
ran always after Windows startup (registry:
HKEY_LOCAL_MACHINE/Software/Microsoft/Windows/CurrentVersion/Run - hope
that's right). But I want also to run another script by Windows shutdown.
Is it possible?

Thanks,
and please reply to my *e-mail*, if possible.

Michal Bozon
Faculty of Science, Charles Univ., Prague, Czech Rep. 

bozon at natur.cuni.cz
http://www.natur.cuni.cz/~bozon




More information about the Python-list mailing list