From 5628a7afb79dbe278e883837b352965e4eb10bd7 Mon Sep 17 00:00:00 2001 From: ema Date: Tue, 20 Aug 2024 01:03:33 +0800 Subject: [PATCH] feat: support delay window such as AnLink --- src/MakeDark.csproj | 6 +++--- src/Program.cs | 20 +++++++++++++++++++- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/MakeDark.csproj b/src/MakeDark.csproj index 01869c1..9f7690d 100644 --- a/src/MakeDark.csproj +++ b/src/MakeDark.csproj @@ -13,9 +13,9 @@ false Favicon.ico makedark - 0.2.0 - 0.2.0 - $(VersionPrefix)0.2.0 + 0.3.0 + 0.3.0 + $(VersionPrefix)0.3.0 Lemutec diff --git a/src/Program.cs b/src/Program.cs index f9c5878..40c137e 100644 --- a/src/Program.cs +++ b/src/Program.cs @@ -57,7 +57,7 @@ public static void Main(string[] args) process.Start(); process.WaitForInputIdle(); - SpinWait.SpinUntil(() => process.HasExited || process.MainWindowHandle != IntPtr.Zero); + _ = SpinWait.SpinUntil(() => process.HasExited || process.MainWindowHandle != IntPtr.Zero, 30000); if (process.HasExited) { @@ -72,6 +72,24 @@ public static void Main(string[] args) Interop.SetRoundedCorners(hWnd); } } + + if (process.HasExited) + { + return; + } + + _ = SpinWait.SpinUntil(() => + { + foreach (nint hWnd in Interop.GetWindowHandleByProcessId(process.Id)) + { + if (!Interop.IsDarkModeForWindow(hWnd)) + { + Interop.EnableDarkModeForWindow(hWnd); + Interop.SetRoundedCorners(hWnd); + } + } + return false; + }, 3000); } } }