From 529576d9726d3fd5cfd8c19d1eff231db63d4bd8 Mon Sep 17 00:00:00 2001 From: whoswhip Date: Wed, 22 Oct 2025 03:30:05 -0400 Subject: [PATCH] feat: ensure anti capture visibility --- Spectrum/Detection/DetectionManager.cs | 13 +++++++++---- Spectrum/Win32.cs | 3 +++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Spectrum/Detection/DetectionManager.cs b/Spectrum/Detection/DetectionManager.cs index 9749098..29a6d50 100644 --- a/Spectrum/Detection/DetectionManager.cs +++ b/Spectrum/Detection/DetectionManager.cs @@ -37,11 +37,12 @@ namespace Spectrum.Detection { while (true) { + var config = mainConfig.Data; try { - if (InputManager.IsKeyOrMouseDown(mainConfig.Data.Keybind) || InputManager.IsKeyOrMouseDown(mainConfig.Data.TriggerKeybind)) + if (InputManager.IsKeyOrMouseDown(config.Keybind) || InputManager.IsKeyOrMouseDown(config.TriggerKeybind)) { - var config = mainConfig.Data; + if (config.DebugMode) stopwatch.Restart(); @@ -268,15 +269,19 @@ namespace Spectrum.Detection MovementPaths.ResetWindMouse(); Thread.Sleep(5); } - if (InputManager.IsKeyOrMouseDown(mainConfig.Data.MenuKey)) + if (InputManager.IsKeyOrMouseDown(config.MenuKey)) { var now = DateTime.Now; if ((now - lastMenuToggle).TotalMilliseconds > 175) { - mainConfig.Data.ShowMenu = !mainConfig.Data.ShowMenu; + config.ShowMenu = !config.ShowMenu; lastMenuToggle = now; } } + if (config.AntiCapture && !Win32.IsWindowHidden) + Win32.EnableAntiCapture(renderer!.window.Handle); + else if (!config.AntiCapture && Win32.IsWindowHidden) + Win32.DisableAntiCapture(renderer!.window.Handle); } catch (Exception ex) { diff --git a/Spectrum/Win32.cs b/Spectrum/Win32.cs index 57b0dc2..b3cbea9 100644 --- a/Spectrum/Win32.cs +++ b/Spectrum/Win32.cs @@ -16,6 +16,7 @@ namespace Spectrum private const int SM_YVIRTUALSCREEN = 77; private const int SM_CXVIRTUALSCREEN = 78; private const int SM_CYVIRTUALSCREEN = 79; + public static bool IsWindowHidden = false; public static (int Width, int Height) GetPrimaryScreenSize() { @@ -40,11 +41,13 @@ namespace Spectrum public static bool EnableAntiCapture(IntPtr windowHandle) { + IsWindowHidden = true; return SetWindowDisplayAffinity(windowHandle, WDA_EXCLUDEFROMCAPTURE); } public static bool DisableAntiCapture(IntPtr windowHandle) { + IsWindowHidden = false; return SetWindowDisplayAffinity(windowHandle, WDA_NONE); } }