How to get currently active window on Win32?

David Brady daves_spam_dodging_account at yahoo.com
Sat Dec 15 20:53:49 EST 2001


Hi all,

More win32all questions... is it possible to get the
handle of the window that currently has the focus? 
win32gui.GetActiveWindow() fails because I'm looking
for a window outside the process of my Python script.

Second question, it looks like PyCWnd supports all of
the MFC functionality that I could want (including
GetTopWindow, ahem) but I can't figure out how to get
at a PyCWnd object.  How can I call these MFC
functions... or do I have to create a Win32 PyCWnd
dialog in order to call from it?

Third, is it possible to call GetWindowPlacement and
SetWindowPlacement from Python?  I'd like to write a
script that manipulates the positions of my open
windows.

Fourth (and last, phew!), is there a way to find out a
window's class?  FindWindow, for example, will look
for a caption or a window class; it's more accurate to
look for window classes (especially when you have six
different apps running whose caption begins with
'Untitled') but I don't see anyway to inspect or get
window classes of running windows from within Python.

Sorry for such demanding question asking... and thank
you in advance for any help rendered.

-dB

=====
David Brady
daves_spam_dodging_account at yahoo.com
I'm feeling very surreal today... or *AM* I?

__________________________________________________
Do You Yahoo!?
Check out Yahoo! Shopping and Yahoo! Auctions for all of
your unique holiday gifts! Buy at http://shopping.yahoo.com
or bid at http://auctions.yahoo.com




More information about the Python-list mailing list