How i can use GetWindowText API function in powershell ?
i tried this way :
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);
}
"@
and i make string builder like this :
$stringbuilder = New-Object System.Text.StringBuilder
$stringbuilder.Capacity =256
i used function like :
$WindowTitless = $ImportDll::GetWindowText($TopWindow, $stringbuilder, 256)
but i got error :
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'."
some one can give me help to use this function ? if you can please write code . tnx.