title: How to get text from a windows control's textbox? and how do I know it's a textbox?
body: <p>I've used spy++ to find the right handle of the wanted windows control, which belongs to a standalone application which isn't managed. 
  Note that the spy++ "property inspector" mentions that this window doesn't have any child (or parent) windows.</p>
  
  <p>I've also managed to get back the name of the window with the following code:</p>
  
  <pre><code>   //the invokes are included aswell
      const int WM_GETTEXT = 0x000D;
      static void Main(string[] args)
      {
          IntPtr handle = new IntPtr(Convert.ToInt32("00070818", 16)); 
          int nChars = GetWindowTextLength(handle); //win32 function
          int length = 200;
          StringBuilder sb = new StringBuilder(length);
          SendMessage(handle, WM_GETTEXT, length, sb);
          Console.WriteLine(sb.ToString());           
  
      }
  </code></pre>
  
  <p>This window has a lot more information than it's title, and that's all I seem to get back with WM_GETTEXT (changing the value of length to 200 didnt help, was a long shot anyway).</p>
  
  <p>Next, I've tried a different approach using UI Automation:</p>
  
  <pre><code>static void Main(string[] args)
  {
      AutomationElement target = AutomationElement.FromHandle(handle);
      TextPattern textPattern = target.GetCurrentPattern(TextPattern.Pattern) as TextPattern;
  }
  </code></pre>
  
  <p>but I got this error back:</p>
  
  <blockquote>
    <p>An unhandled exception of type 'System.InvalidOperationException' occurred in UIAutomationClient.dll</p>
    
    <p>Additional information: Unsupported Pattern.</p>
  </blockquote>
  
  <p>To top it off, I've also tried using Microsoft Inspect.exe, but it failed to focus on the text in the window, both in UI automation and MSAA mode. </p>
  
  <hr>
  
  <p>Does it mean that the data cant be achieved with UI Automation?? or should am I just using the wrong methods/types?</p>
  
  <p>Is there another way to get the data from this window other than using GetWindowText, WM_GETTEXT, or UI automation??</p>
  
  <p>I'm fairly new to this stuff, but I'm trying my best to learn. In addition I've have no current leads so any helpful comment/answer would be much appreciated!!
  if you do answer <strong>please be sure to include helpful keywords</strong> so i'll be able to learn more about your solutions</p>