fetching text from the screen

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Tue Jun 19 01:27:08 CEST 2007

En Mon, 18 Jun 2007 09:13:16 -0300, Juergen Kareta <kareta at web.de>  

> I'm thinking about a python script which fetch some text from the screen
> independent of what application provides the text on the screen. In this
> regard it should be similar to the babylon software: www.babylon.com
> Here my thoughts:
> 1) getting the mouse position
> 2) calculate a adequate rectangle around the mouse position
> 3) fetch the screen content in this rectangle
> 4) use a OCR library to get the text out of 3)
> 5) do something usefull with it.

On Windows, I'd try first using WindowFromPoint to get a window handle,  
and the sending it a WM_GETTEXT message. This should work for all windowed  
controls that contain text of some kind. I'd use your generic approach  
when this doesn't work.

Gabriel Genellina

More information about the Python-list mailing list