Not through win32com, no, because the API is not COM. However, most of
the Win32 API is directly callable through the pywin32 extensions in
some way. Most of what you need for this task is in win32gui.
In most dialog boxes, all of the strings you see are static text
controls, each with its own window handle. When you have the window
handle, you can call GetWindowText to fetch the text within in. The
trick is finding the window. The job will be much easier if you have a
window "spy" utility, like Microsoft's spyxx.exe, or Borland's
winspecter. Using that, you can see the tree of parent/child windows
that make up the dialog.
There are two ways to get at a specific window control. Dialog controls
often have an "id". This is the same concept as the "id" in wxPython,
but where wxPython is moving away from the "id" concept, when you're
programming in C or C++, the id is the only way to get at the controls.
If you can see in the spy utility that the "copyright" string window has
an id, then you're job is easy. Find the window handle of the dialog,
call GetDlgItem (in win32gui) to get the handle of that control, and
call GetWindowText (also in win32gui) to get the string.
Unfortunately, static text controls often do not have an id,
particularly if they do not need to be changed. In that case, the job
is trickier. You end up having to enumerate through the list of child
windows for the dialog, and hard-coding the knowledge that the static
text control is (for example) the fourth subwindow in the list.
ยทยทยท
On Thu, 29 Dec 2005 22:31:44 +0000, Vyacheslav Sotnikov <bsdforfree@rambler.ru> wrote:
Robin Dunn wrote:
Vyacheslav Sotnikov wrote:
Hi there.
I've got some win32 application (that can be wxPython application), that
have menu item "About" (some DialogBox) that contains string "Copyrigth
2005 by Joe". Can i programmatically (with python) to obtain that string
from DialogBox? E.g. i run the application, then run my python script
and it extracts and prints the string "Copyrigth 2005 by Joe". Can i do
that?
If it's a wx.Dialog then you can traverse it's children looking for the
control that that displays the text. If it's an arbitrary window that
you have the HWND handl for then you can use win32 api functions to do
something similar.Thats it. But i dont know c/c++ so i cant use pure win32 api. Can i do
this with win32com python extension?
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.