C # - reading text from an existing process

We need to read the text of an existing VB6 application. Therefore, we use the FindWindow, GetWindowText and EnumChildWindows methods from kernel32 and can enumerate and read the displayed text in this process.

We can read 90% of the text with our method, but in general there is a certain control (or field) that we cannot read.

We cannot target text to be read with UI spyware, so I assume they should display it directly on screen using GDI / GDI +. They cannot use the control or window to render the text we want.

Is there a way to determine how they display the text and maybe read it?

We don't want to grab the hDC window and rasterize it and somehow reverse-CAPTCHA the text ... this can be a nightmare.

SOLUTION: . We found that only 2-3 phrases in this field could be used for this, compared to actual text recognition. So we're going to map it to a bitmap and compare it to 2-3 pre-saved bitmaps so we can just compare pixel by pixel.

The most correct answer led us to this decision.

+2


source to share


1 answer


If they are drawing directly to the surface, there is no way to get the text without some weird OCR data.

Update : After thinking about your problem, I think doing what you described (grabbing the hDC window and creating a bitmap from it) would be a relatively straightforward task (relative to trying to intercept the APIs that displayed the text in the first place).



It wouldn't be as difficult as doing OCR in handwriting, for example. As long as you can determine the font used by a Visual Basic 6 application to draw text, and as long as the text you want to clear is drawn to the same place in the form every time, it would be relatively easy to break drawn text into discrete characters (like little little bitmaps) and then compared each to a pre-generated set of characters that you drew with the same font of the same size. Symbols will perfectly match the pixel base.

A problem may arise if the program runs on different systems and draws text with different fonts.

+1


source







All Articles