capturing text from a GUI window

Myles Strous myles at geocities.com
Thu Mar 10 00:39:05 EST 2005


Earl Eiland wrote:
> This sounds like just what I need.  What is COM, and where do I get
it?

Also worth checking out:

Simon Brunning's WinGuiAuto - control/query of windows and controls,
including the function getEditText to read the text in an edit control.
See http://www.brunningonline.net/simon/blog/archives/001129.html
You'll probably also need something like Winspector to get class names
etc - see http://www.windows-spy.com/

AutoIt3 - freeware, has a DLL version that is COM-controllable (after
registration using "regsvr32 AutoItX3.dll" from a console window). I
must admit that so far I've only ever used version 2 through COM.
Includes functions such as ControlGetText and WinGetText, and throws in
a separate spy/info program as well. See
http://www.autoitscript.com/autoit3/

COM (component object model) - inter-component communication
technology. See http://www.microsoft.com/com/default.mspx

Makes it easy for programs with COM client functonality to use/control
functions exposed in a COM server program (well, that's the Dispatch
part of it that's applicable to your situation, it's apparently a fair
bit more than that).

Mark Hammond's Python for Windows extensions (thank you Mark Hammond!),
also known as Win32All or PyWin32, adds COM client funcionality to
Python.
(Note: Python+PyWin32 also does COM server stuff, but you don't need to
know about that.)

Use the COM Makepy utility (under the Tools menu) in PythonWin (the IDE
that comes with the Python for Windows extensions) to get a nice
interface module for your chosen COM server component, then just call
the functions in the interface module (or whatever the correct
technical name is for the generated .py file).

Worth reading:
http://www.python.org/windows/win32com/QuickStartClientCom.html

Example Python uses of COM server components:
http://www.boddie.org.uk/python/COM.html
http://www.pyzine.com/Issue007/Section_Articles/article_PythonCOM.html
http://schram.net/articles/python/eudora.html
http://www.daniweb.com/code/snippet208.html
http://tinyurl.com/42rxa

(Using a COM component is very similar in a variety of programming
languages)

In case you don't already have the Python for Windows extensions, or
the ActiveState Python distribution which includes them: see
http://sourceforge.net/projects/pywin32/

Regards, Myles.




More information about the Python-list mailing list