0

I'm trying to get text from terminal window.

https://www.attachmate.com/products/extra/

it looks like below:

enter image description here

I'm using WM_GETTEXT to get text from this terminal window. As you can see above, the window has text (in green) but i'm not able to get anything, even after trying out all windows and child windows under this applications.

the code i use is:

function TForm1.fn_get_text(): string;
var
  NpWnd, NpEdit: HWnd;
  Buffer: string;
  BufLen: Integer;
begin

  Memo1.Clear;
  NpWnd := FindWindow('#32769', nil);
  if NpWnd <> 0 then
  begin
     //NpEdit := FindWindowEx(NpWnd, 0, 'Afx:400000:202b:10003:6:0', nil);
     //if NpEdit <> 0 then
     //begin
        BufLen := SendMessage(NpWnd, WM_GETTEXTLENGTH, 0, 0);
        SetLength(Buffer, BufLen + 1);
        SendMessage(NpWnd, WM_GETTEXT, BufLen, LParam(PChar(Buffer)));
        Memo1.Lines.Text := Buffer;
     //end;
  end;
end;

I used Winspy++ to get all window classes. In Win spy++, different window classes look like below:

enter image description here

I tried all window classes under Extra.exe . But nothing seems to be able to get me the text from terminal window. Could anyone please provide me some tips to identify the issue?

jimsweb
  • 1,082
  • 2
  • 17
  • 37
  • 1
    Screen scraping is probably your best bet. – Jonathan Potter Feb 07 '16 at 02:48
  • 3
    Probably the "terminal" is not a native control, maybe created using a graphic library or something (just guessing). – cdonts Feb 07 '16 at 03:02
  • 3
    That product page says they offer an API, even as Automation, you could try that. – Ondrej Kelle Feb 07 '16 at 07:18
  • What return values do you get from WM_GETTEXTLENGTH and WM_GETTEXT? – Blurry Sterk Feb 07 '16 at 07:19
  • 1
    @Blurry the text isn't in an EDIT control – David Heffernan Feb 07 '16 at 07:23
  • @blurry, i get the title from window class 'SDImainframe' . It's length is 14. No other windows give any text. – jimsweb Feb 07 '16 at 11:26
  • @jonathan, can you please share some links or so, so that i can take look at this 'screen scraping'. thanks in advance. – jimsweb Feb 07 '16 at 11:27
  • @jims takes a screenshot and use ocr to extract text. But why not use the api? – David Heffernan Feb 07 '16 at 14:12
  • @Dave, I do not want to use the API, because i like my application to be generic one that can be used across multiple terminal emulators like TN3270, Rumba, extra attachamte, IBM PCOM etc.. If i start using the API, my application will be tied to Extra attachmate.. Do you know good OCR library (Free /commercial) that has reasonable response time? – jimsweb Feb 07 '16 at 21:33
  • 2
    Using the Extra API won't tie your program to Extra unless you choose to use that API *exclusively*. So don't choose that. Use the Extra API to talk to Extra, and use other methods to talk to other applications. – Rob Kennedy Feb 07 '16 at 21:41
  • @jimsweb `WM_GETTEXT` copies the text *that corresponds to a window* into a buffer, not the text *being displayed*. It won't return a text that has been displayed using `DrawText` for example. But there is hope if the *Xtra extreme* output window is cmd-based. Can you tell me if you have *cmd* also running whenever you run *extreme* ? In this case, you will be able to use the console functions `AttachConsole`, `ReadConsoleOutput`, etc. to read the text. – mikedu95 Feb 09 '16 at 14:00
  • no. Command window never runs along with this emulator. – jimsweb Feb 09 '16 at 22:01

0 Answers0