Greetings

It is necessary to get access to controls from an application written using Framework 2.0. Namely, read the text property, get the children, if it is a TreeView, etc.

I would be grateful for links or examples, even from afar resembling such actions.

Thank.

  • Forgot to clarify. Third-party non-WinForms. I think that is written in Visual C ++. - pavelnik
  • using Microsoft Active Accessibility (MSAA). example here - Stack

2 answers 2

I don’t know if it can be done through Windows Forms, but through WinAPI you can. As far as I know, it is also available in C # and is in some namespace, I do not remember which one.

The algorithm is as follows: you send a WM_GETTEXT message to the control, passing a pointer to an array of bytes. In it, you get a C-string. Now it needs to be somehow translated into string. I do not know .NET, I can not say how. This string will be the text of the control.

Getting child elements through WinAPI is more complicated. I do not know how to do it.

  • one
    Interesting offer. I will smoke in this direction. - pavelnik
  • @pavelnik is easier with Automation. C # example here - Stack

There is an excellent library NUnit Forms , it allows you to manage other people's forms. True, its main purpose is testing UI. But I think she will solve a similar problem.

  • one
    Thanks for the answer. Judging by the description is only suitable for WinForms. - pavelnik