FW: Win32all documentation?

Neil Hodgson nhodgson at bigpond.net.au
Mon Dec 10 16:31:37 EST 2001


David Brady:

> 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.

   The problem here is that the Win32 API is *huge*, the Word object model
is quite large, and there are a lot of other COM servers that can be used
with win32com. Even if someone were to put in the effort for the current
version of these interfaces, there will be new versions every year or two
requiring ever increasing work. Even Microsoft doesn't provide Win32 API
documentation for VB - instead you get to use the C-oriented documentation
which has to be interpreted into VB terms. The opposite applies to Word with
documentation for VB but not for C/C++.

> 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):

   With the "ActivePython Documentation" downloaded with ActivePython
2.1.212 entering FindWindow in the search box yields several entries showing
that the win32ui and win32gui modules host this function.

> 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.

   SendInput may be the right level to work at but this is not wrapped by
win32all. calldll is the generic low level escape that can be used when
there is no nicely wrapped high level function. SendKeys is really a quite
fragile mechanism to use for running other applications and higher level
calls should be used where possible. PostMessage(WM_KEYDOWN | WM_LBUTTONUP |
...) may be a reasonable level to use when dealing with an application you
have written where you can fix problems with input code rather than having
to work around them.

   Neil





More information about the Python-list mailing list