ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> python-win32
python-win32
Re: [python-win32] System wide text selection
by Mark Mc Mahon other posts by this author
Apr 18 2006 10:24AM messages near this date
Re: [python-win32] System wide text selection | [python-win32] Problem with installer for pywin32 with Python 2.5
Hi,

You might want to look into pyHook (google for it - I don't have a
link right now).

Another option that might be much easier is to setup a global hotkey,
where the user selects the word, and clicks the hotkey (and you pop up
a window at that point with the translation(s).  You could probably
use WM_COPY to get teh text into teh clipboard and then get it from
there using your app (though it would be good manners to save teh
existing data first :-) ).

Mark

On 4/18/06, Tim Roberts <timr@[...].com>  wrote:
>  On Mon, 17 Apr 2006 19:54:14 +0200, Dao Duy Huy <dao@[...].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
>  >position...
>  >
>  >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@[...].com
>  Providenza & Boekelheide, Inc.
> 
>  _______________________________________________
>  Python-win32 mailing list
>  Python-win32@[...].org
>  http://mail.python.org/mailman/listinfo/python-win32
> 
_______________________________________________
Python-win32 mailing list
Python-win32@[...].org
http://mail.python.org/mailman/listinfo/python-win32
Thread:
Dao Duy Huy
Tim Roberts
Mark Mc Mahon

Privacy Policy | Email Opt-out | Feedback | Syndication
© 2004 ActiveState, a division of Sophos All rights reserved