🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.python
Article #49

win32ui.GetActiveWindow() problem

#49
From: Michal Bozon
Date: Mon, 13 Mar 2000 00:00
42 lines
2324 bytes
__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@natur.cuni.cz
http://www.natur.cuni.cz/~bozon
Technical Details
Message-ID: <Pine.OSF.4.10.10003131737550.6506-100000@prfdec.natur.cuni.cz>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fd557,1afca329daabaac3,start
X-Google-Attributes: gidfd557,public
X-Google-Thread: 10dd18,1afca329daabaac3,start
X-Google-Attributes: gid10dd18,public
From: Michal Bozon <bozon@natur.cuni.cz>
Subject: win32ui.GetActiveWindow() problem
Date: 2000/03/13
Message-ID: <Pine.OSF.4.10.10003131737550.6506-100000@prfdec.natur.cuni.cz>
X-Deja-AN: 596922454
X-NNTP-Posting-Host: prfdec.natur.cuni.cz
X-Trace: 13 Mar 2000 18:20:29 +0100, prfdec.natur.cuni.cz
Organization: Ceske Vysoke Uceni Technicke, Praha
Content-Type: text/plain; charset=us-ascii
MIME-Version: 1.0
Newsgroups: comp.lang.python,cz.comp.lang.python