diff --git a/crates/client/Cargo.toml b/crates/client/Cargo.toml index e7e327a..b97a512 100644 --- a/crates/client/Cargo.toml +++ b/crates/client/Cargo.toml @@ -41,4 +41,5 @@ windows = { version = "0.54", features = [ "Win32_UI_Shell", "Win32_System_Console", "Win32_System_ProcessStatus", + "Win32_Graphics_Dwm", ] } diff --git a/crates/client/src/windows_mgmt.rs b/crates/client/src/windows_mgmt.rs index 72385cb..ab84e6a 100644 --- a/crates/client/src/windows_mgmt.rs +++ b/crates/client/src/windows_mgmt.rs @@ -7,6 +7,7 @@ use std::collections::HashMap; mod win_impl { use super::*; use windows::Win32::Foundation::{BOOL, HWND, LPARAM}; + use windows::Win32::Graphics::Dwm::{DwmGetWindowAttribute, DWMWA_CLOAKED}; use windows::Win32::UI::WindowsAndMessaging::{ BringWindowToTop, EnumWindows, GetWindowTextW, IsWindowVisible, SetForegroundWindow, ShowWindow, @@ -38,6 +39,18 @@ mod win_impl { list } + fn is_cloaked(hwnd: HWND) -> bool { + let mut cloaked: u32 = 0; + unsafe { + DwmGetWindowAttribute( + hwnd, + DWMWA_CLOAKED, + &mut cloaked as *mut u32 as *mut _, + std::mem::size_of::() as u32, + ).is_err() == false && cloaked != 0 + } + } + fn hwnd_title(hwnd: HWND) -> String { let mut buf = [0u16; 512]; let len = unsafe { GetWindowTextW(hwnd, &mut buf) }; @@ -98,6 +111,9 @@ mod win_impl { if !visible { continue; } + if is_cloaked(*hwnd) { + continue; + } let title = hwnd_title(*hwnd); if title.is_empty() { continue;