Getting UI text from external app in C#

Question :

Getting UI text from external app in C#,

Answer :

Is it possible to get UI text from an external application in C#.

In particular, is there a way to read Unicode text from a label (I assume it’s a normal Windows label control) from an external Win32 app that was written by a 3rd party? The text is visible, but not selectable by mouse in the UI.

I assume there is some accessibility API (e.g. meant for screen readers) that allows this.

Edit: Currently looking into using something like the but would still appreciate any other leads

Read More  What problems can be solved, or tackled more easily, using graphs and trees?


If you just care about the standard Win32 label, thenwill work fine, as outlined in the other answers.

There is an accessibility API –  – for standard labels, it too uses WM_GETTEXT behind the scenes. One advantage to it, however, is that it can get text from several other types of controls, including most system controls, and often UI using non-system controls – including WPF, text in IE and Firefox, and others.

// compile as:  // csc file.cs /r:UIAutomationClient.dll /r:UIAutomationTypes.dll /r:WindowsBase.dll  using System.Windows.Automation;  using System.Windows.Forms;  using System;    class Test  {      public static void Main()      {          // Get element under pointer. You can also get an AutomationElement from a              // HWND handle, or by navigating the UI tree.          System.Drawing.Point pt = Cursor.Position;          AutomationElement el = AutomationElement.FromPoint(new System.Windows.Point(pt.X, pt.Y));          // Prints its name - often the context, but would be corresponding label text for editable controls. Can also get the type of control, location, and other properties.          Console.WriteLine( el.Current.Name );      }  }  

That’s the answer Getting UI text from external app in C#, Hope this helps those looking for an answer. Then we suggest to do a search for the next question and find the answer only on our site.

Read More  Best implementation for Key Value Pair Data Structure?

Disclaimer :

The answers provided above are only to be used to guide the learning process. The questions above are open-ended questions, meaning that many answers are not fixed as above. I hope this article can be useful, Thank you