FW: Win32all documentation?

David Brady daves_spam_dodging_account at yahoo.com
Mon Dec 10 11:59:40 EST 2001


> -----Original Message-----
> From: David Bolen [mailto:db3l at fitlinxx.com]
> Sent: Friday, December 07, 2001 8:31 PM
> To: python-list at python.org
> 
> (Can there be anything but "Windows-specific"
> portions of this query
>  given that we're talking about win32all? :-))

Um... yes, though I may be splitting hairs.  I've got
a pretty solid grasp of Python in general, and I've
been programming Windows in C/C++ for nearly 10 years.
 The part I don't understand clearly is win32all
*itself*.  I know *how* to enumerate windows in C; I
just don't know how to get there from Python.

Over the weekend I walked through the entire win32all
installation and found a lot of demos, many of which
appear to be most illuminating.  But they still only
shine points of light in a dark corner, and I want to
turn on the Big Light Overhead.  If there were
win32all documentation somewhere, something at least
as complete as the documentation like the Python
module dox
(http://www.python.org/doc/current/modindex.html), I
would be in fat city.

I own Mark's book, and I've read most of it.  While it
is excellent, it doesn't provide a reference so much
as a lot more in-depth examples.  For example, filling
out and printing a Microsoft Word template document
using win32com is demonstrated, but no further data is
forthcoming on what *else* you can do with MS Word
from win32com.  Like, for example, how to open Word to
a blank document and create and format a documnt from
scratch.  If I could just see all the methods, objects
and classes of win32all, I could probably figure out
how to hook up the rest of the stuff I need.

Forgive me if I'm sounding whiny.  I'm beating my head
against a brick wall here, and I'm willing to admit
it's my head's fault... if someone will just show me
the door in the wall to walk through.  In defense of
my head, however, the wallbuilder and doormaker might
consider marking the door more clearly.  (Unless
they're sickos who enjoy this sort of thing.  :-)

> MSDN is really the right place.

This was the second portion of my query; in specific I
was looking for WSH documentation.  After the comment
here that "Python can do everything better than WSH,
SendKeys is about the only useful part of WSH", I'm
willing to try and find other solutions.

I know from MSDN, for example, how to enumerate all
the windows in the system and how to get and change
the caption of a window.  For this portion of our
program, I am asking how to do it from Python.  If
there isn't a "win32.enumeratewindows" method, then
how can I call the windows API functions FindWindow()
and EnumWindows()?  I do not see them listed when I do
a dir(win32api):

>>> for f in dir(win32api):
... 	if f.upper().find('FIND') != -1:
... 		print f
... 		
FindCloseChangeNotification
FindExecutable
FindFiles
FindFirstChangeNotification
FindNextChangeNotification

>>> for f in dir(win32api):
... 	if f.upper().find('ENUM') != -1:
... 		print f
... 
EnumResourceNames
RegEnumKey
RegEnumValue

...I infer from my reading that the win32api functions
of Python are considered fairly complete, so I'm
willing to assume that these functions are missing
because I'm looking in the wrong place, or that
they're implemented in a more Python-friendly way
altogether and using the api in this case is a poor
choice.  If someone would please show me how these
ruby slippers worked, I'm sure I could go home....

> Perhaps if you suggested some specific questions you
> may have in terms
> of trying to interact with the API (or WSH, or
> whatever), we'd be able
> to be more specific with pointers to information.

Certainly.  And THANK YOU ALL for getting this far
through my incredibly long rant.  Here are the
specificy problems I'm trying to solve at the moment,
and the Python hurdles I have yet to clear with them.

I have two main applications I'm trying to create at
the moment:

1. Testing GUI code written in C++.  It VERY nice to
be able to SendKeys() a few hundred bytes of text
every time I want to test the text handling portion of
my GUI.  I'd also like to be able to send mouse clicks
to the application; in this way I could simulate
actually having a human at my program typing and
clicking away, and I can verify that my code changes
have broken nothing.  I'd also like to be able to grab
a screenshot of just that window; much later in
testing I can use this to verify that the program's
output is correct.

So, 3 things:
- How to find an application running in the system,
preferrably by window class, and activate one of its
child windows, which may be positioned randomly on the
screen.  There may be multiple instances of the window
class running, I'd like to be able to inspect them to
be able to pick the correct one.
- How to send mouse actions to a window.
- How to capture a screenshot of a window.

2. Whenever I install or reinstall an operating
system, I have about 20 different applications that
have to be installed and have their registration codes
entered.  The process AFTER the OS is installed takes
about four hours.  I'd like a script that launches
their installers, clicks through their install
interfaces, and types in my user and registration info
automatically.  In this way, I could fire up a new
machine, launch the script, and let it install and
register my software, rebooting as necessary.  Once
that's done, I usually reorganize the Programs folder
inside the Start Menu so that I can more easily
navigate it by keyboard (for example, renaming the
4,219,376 applications whose names start with
"Microsoft" so that hitting "O" launches Office and
"W" launches Word.

Three things, again:
1 - Finding the start menu folder so the script can
put itself there to continue running after each
reboot.
2 - Launching an app and then monitoring it, waiting
for it to die.
3 - Walking through the start menu shortcuts and
renaming them.

Phew.  I'm sorry this is such a long list.  That's why
I tried to abstractify my question.  :-) 
Unfortunately, I described the abstraction poorly, or
chose the wrong abstraction altogether.  Specific help
for any of these questions is certainly welcome,
though if anyone sees now the "correct" way to think
about these problems--in such a way that I can get the
information I need to get them working--I would also
be grateful.

Thank you very much,

-dB
P.S. Bonus question.  How can I change the desktop
background image in Win32 from Python?  Thanks again!
P.P.S. No disrespect is intended towards Hammond &
Robinson, their book, or their documentation as
presented on the ActiveState site.  I'm having
difficulty, yes, but I'm grateful I've got as much
information as I do.

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

__________________________________________________
Do You Yahoo!?
Send your FREE holiday greetings online!
http://greetings.yahoo.com




More information about the Python-list mailing list