Pobranie nazwy aktywnego okna

0

Jak moge zrobić wiem na pewno że przez API pobranie nazwy okna (tytułu jego)... gdy np nacisne myszką on automatycznie go pobierze...

0

Dobra podaje rozwiązanie tego... Naszczęście poradziłem sobie;pp

[DllImport("user32.dll")]
public static extern IntPtr GetForegroundWindow();
[DllImport("user32", SetLastError=true, CharSet=CharSet.Auto) ]
static extern int GetWindowText(IntPtr hWnd, [Out] StringBuilder lpString, int nMaxCount);
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
static extern int GetWindowTextLength(IntPtr hwnd);

public static IntPtr Hwnd()
{
return GetActiveWindow();
}
public string GetText(IntPtr hwnd)
{
int length = GetWindowTextLength(hwnd);
StringBuilder sb = new StringBuilder(length + 1);
GetWindowText(hwnd, sb, sb.Capacity);
return sb.ToString();
}
...

i w jednym z voidów

  ...

maskedTextBox1.Text = GetText(Hwnd());

1 użytkowników online, w tym zalogowanych: 0, gości: 1