Sign in to follow this  
kaliopi

reading text in window

Recommended Posts

I'm fairly newbie to Win32. I wonder if the win32 sdk/directx api can read text from a rendered window? I'm assuming by the time the text is rendered on WINMAIN the graphics releases all it's data to the graphics hardware. It seems to me that the only solution? Analyze pixels in the graphics handle - perhaps an api?

Share this post


Link to post
Share on other sites
Quote:
I'm assuming by the time the text is rendered on WINMAIN the graphics releases all it's data to the graphics hardware.

This all depends how the window renders it text.
If it's done using a static control or an edit control then there's a window handle associated with them.
Just send a WM_GETTEXT to that window.

If the window is rendered using the TextOut, DrawText GDI functions, then the text is discarded (from memory) after the call (the calling application might still have the text around but that's usually not very helpful).
In this case you could use window hooks to intercept the calls and get the text from there.

If the window is rendered by other means (drawing to a bitmap using custom code etc), then there's only image analysis left.
This could be very hard, but also not to bad if there's only a few fonts and font sizes used, and that they are known by you.

My 2c

Edit: The process of retrieving text from general images is called OCR (Optical Character Recognition).
Using google I found an open source project doing something like that here.
Discalmer: Haven't tried the library above...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this