I want to get all Windows that I could take a screenshot, application windows. I am trying to use EnumWindows
.
public delegate bool CallBackPtr(IntPtr hwnd, int lParam);
[DllImport("user32.dll")]
private static extern int EnumWindows(CallBackPtr callPtr, int lPar);
public static List<IntPtr> EnumWindows()
{
var result = new List<IntPtr>();
EnumWindows(new User32.CallBackPtr((hwnd, lParam) =>
{
result.Add(hwnd);
return true;
}), 0);
return result;
}
However this is returning more Windows than I expect, such as:
I want to grab only Windows like Visual Studio, Skype, Explorer, Chrome...
Should I be using another method? Or how do I check if it is a window I want to grab?