[python-win32] System wide text selection

Tim Roberts timr at probo.com
Tue Apr 18 19:13:56 CEST 2006

On Mon, 17 Apr 2006 19:54:14 +0200, Dao Duy Huy <dao at tum.de> wrote:

>I'm  writing  a dictionary german <> vietnamese for free use, which
>should react on the mouse-click like babylon.
>You click on a german word in any win-program and the dict program will 
>show you the translation in vietnamese and vice versa.
>But i couldn't find the way how i can select the word with the mouse
>Can you show me how you solve the problem?

This is a difficult problem to solve, and it may be that Python is not
the right language for it.

You first have to figure out which window contains the point you want. 
Then, you have to figure out what KIND of window that is (text box, rich
text control, static text, list box, custom control).  Then, you use
THAT knowledge to decide how to ask the control to translate the X,Y
coordinate into a row and column position.  Then, you can fetch the
whole contents of that window, find the exact character, and work
backwards and forwards to find the word boundaries.  Note that for some
applications (like Word), you will have to use Word APIs to do this.

It is complicted.  You will want to do a lot of web searching to see if
you can find some good sample code.

Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.

More information about the Python-win32 mailing list