Seyed Mousa
Seyed Mousa

Reputation: 43

how can access and read the caption of Label in other program

there is a program that i guess it made with Visual Basic class. and i dont have source code and i dont change it. it has a MainForm and there is a Frame into MainFrom and there is a Label into Frame . the name of Label is Label1 . this program show some data with Label1 . i want to read the caption of Label1 with my program . my program is in delphi . i can access to handle of mainform and frame with their title or their class , as fallow:

Hnd := FindWindow('ThunderRT6FormDC', nil); // find handle of mainForm

Hnd2 := FindWindowEx(Hnd, 0, 'ThunderRT6Frame', nil); // find handle of Frame in mainform

but i dont know how can access or read the caption of Label1 . please help me ...

Upvotes: 4

Views: 852

Answers (1)

David Heffernan
David Heffernan

Reputation: 613372

Here are the things that you can try:

  1. Use Spy++, WinSpy or similar to see if the control is windowed. If so you should be able to extract the text with WM_GETTEXT.
  2. Otherwise, use InspectUI to see if the program is automatable. If so use UIAutomation.
  3. Otherwise, inject some VB code into the program and hack the label text out. That's going to require reverse engineering this other program and a deep knowledge of VB and the GUI framework that the program uses.
  4. As a final option, take a screenshot and use OCR to read the label.

Frankly, if the first two options prove to be not available I would think OCR is actually the easiest.

Upvotes: 5

Related Questions