diff --git a/src/modules/imageresizer/ui/App.xaml.cs b/src/modules/imageresizer/ui/App.xaml.cs index 5d1148150f..82f6478f4f 100644 --- a/src/modules/imageresizer/ui/App.xaml.cs +++ b/src/modules/imageresizer/ui/App.xaml.cs @@ -26,6 +26,8 @@ namespace ImageResizer protected override void OnStartup(StartupEventArgs e) { + // Fix for .net 3.1.19 making Image Resizer not adapt to DPI changes. + NativeMethods.SetProcessDPIAware(); var batch = ResizeBatch.FromCommandLine(Console.In, e?.Args); // TODO: Add command-line parameters that can be used in lieu of the input page (issue #14) diff --git a/src/modules/imageresizer/ui/Utilities/NativeMethods.cs b/src/modules/imageresizer/ui/Utilities/NativeMethods.cs index a773ca2921..f55aef4d2a 100644 --- a/src/modules/imageresizer/ui/Utilities/NativeMethods.cs +++ b/src/modules/imageresizer/ui/Utilities/NativeMethods.cs @@ -19,6 +19,9 @@ namespace ImageResizer.Utilities [DllImport("user32.dll")] internal static extern uint SendInput(uint nInputs, INPUT[] pInputs, int cbSize); + [DllImport("user32.dll", SetLastError = true)] + internal static extern bool SetProcessDPIAware(); + [StructLayout(LayoutKind.Sequential)] public struct INPUT { diff --git a/src/modules/launcher/PowerLauncher/App.xaml.cs b/src/modules/launcher/PowerLauncher/App.xaml.cs index ac57245435..801df1db24 100644 --- a/src/modules/launcher/PowerLauncher/App.xaml.cs +++ b/src/modules/launcher/PowerLauncher/App.xaml.cs @@ -93,6 +93,9 @@ namespace PowerLauncher private void OnStartup(object sender, StartupEventArgs e) { Log.Info("On Startup.", GetType()); + + // Fix for .net 3.1.19 making PowerToys Run not adapt to DPI changes. + PowerLauncher.Helper.NativeMethods.SetProcessDPIAware(); var bootTime = new System.Diagnostics.Stopwatch(); bootTime.Start(); Stopwatch.Normal("App.OnStartup - Startup cost", () => diff --git a/src/modules/launcher/PowerLauncher/Helper/NativeMethods.cs b/src/modules/launcher/PowerLauncher/Helper/NativeMethods.cs index ac12f0db32..369dd43498 100644 --- a/src/modules/launcher/PowerLauncher/Helper/NativeMethods.cs +++ b/src/modules/launcher/PowerLauncher/Helper/NativeMethods.cs @@ -40,6 +40,9 @@ namespace PowerLauncher.Helper [DllImport("user32.dll")] internal static extern IntPtr SetForegroundWindow(IntPtr hWnd); + [DllImport("user32.dll", SetLastError = true)] + internal static extern bool SetProcessDPIAware(); + [DllImport("user32.dll")] internal static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);