title: How i can use GetWindowText API function in powershell?
body: <p>How i can use GetWindowText API function in powershell ?</p>
  
  <p>i tried this way : </p>
  
  <pre><code>    Add-Type @"
    using System;
    using System.Runtime.InteropServices;
    public class UserWindowss {
      [DllImport("user32.dll")]
      public static extern IntPtr GetWindowText(IntPtr hWnd, System.Text.StringBuilder text, int count);
  }
  "@
  </code></pre>
  
  <p>and i make string builder like this : </p>
  
  <pre><code>$stringbuilder = New-Object System.Text.StringBuilder
  $stringbuilder.Capacity =256
  </code></pre>
  
  <p>i used function like : </p>
  
  <pre><code>$WindowTitless = $ImportDll::GetWindowText($TopWindow, $stringbuilder, 256)
  </code></pre>
  
  <p>but i got error : </p>
  
  <pre><code>ERROR: test: Failed to get active Window details. More Info: Exception calling "GetWindowText" with "3" argument(s): "Unable to find an entry point named
  ERROR: 'GetWindowText' in DLL 'user32.dll'."
  </code></pre>
  
  <p>some one can give me help to use this function ? if you can please w<strong>rite code</strong> . tnx.</p>