Added function to get all Wnd32s. This is not recommended but might be useful for some things

This commit is contained in:
CreepyCrafter24 2020-01-07 17:59:32 +01:00
parent 40f88649f1
commit 2c26188fd9
2 changed files with 7 additions and 3 deletions

View File

@ -11,6 +11,7 @@ namespace CC_Functions.Misc
{ {
public static bool forceWindows = false; public static bool forceWindows = false;
private static byte[] _fingerPrint; private static byte[] _fingerPrint;
private static readonly string HIDClasses = @"Win32_Processor:UniqueId private static readonly string HIDClasses = @"Win32_Processor:UniqueId
Win32_Processor:ProcessorId Win32_Processor:ProcessorId
Win32_Processor:Name Win32_Processor:Name

View File

@ -28,7 +28,10 @@ namespace CC_Functions.W32
public static Wnd32 foreground() => fromHandle(GetForegroundWindow()); public static Wnd32 foreground() => fromHandle(GetForegroundWindow());
public static Wnd32[] getVisible() public static Wnd32[] getVisible() =>
getAll().Where(s => IsWindowVisible(s.hWnd) && !string.IsNullOrEmpty(s.title)).ToArray();
public static Wnd32[] getAll()
{ {
WindowHandles = new List<IntPtr>(); WindowHandles = new List<IntPtr>();
if (!EnumDesktopWindows(IntPtr.Zero, FilterCallback, IntPtr.Zero)) if (!EnumDesktopWindows(IntPtr.Zero, FilterCallback, IntPtr.Zero))
@ -288,8 +291,8 @@ namespace CC_Functions.W32
private static bool FilterCallback(IntPtr hWnd, int lParam) private static bool FilterCallback(IntPtr hWnd, int lParam)
{ {
StringBuilder sb_title = new StringBuilder(1024); StringBuilder sb_title = new StringBuilder(1024);
GetWindowText(hWnd, sb_title, sb_title.Capacity); GetWindowText(hWnd, sb_title, 1024);
if (IsWindowVisible(hWnd) && string.IsNullOrEmpty(sb_title.ToString()) == false) WindowHandles.Add(hWnd); WindowHandles.Add(hWnd);
return true; return true;
} }