diff --git a/Flow.Launcher.Test/MainWindowTest.cs b/Flow.Launcher.Test/MainWindowTest.cs new file mode 100644 index 00000000000..7f0d11ff85d --- /dev/null +++ b/Flow.Launcher.Test/MainWindowTest.cs @@ -0,0 +1,17 @@ +using System.Reflection; +using NUnit.Framework; + +namespace Flow.Launcher.Test; + +public class MainWindowTest +{ + [Test] + public void ShouldSuppressWindowAutomationMessage_ForWmGetObjectOnly() + { + var method = typeof(MainWindow).GetMethod("ShouldSuppressWindowAutomationMessage", BindingFlags.NonPublic | BindingFlags.Static); + + Assert.That(method, Is.Not.Null); + Assert.That((bool)method.Invoke(null, [0x003D]), Is.True); + Assert.That((bool)method.Invoke(null, [0x0112]), Is.False); + } +} diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 4866c0deae6..453701960e8 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -68,6 +68,7 @@ public partial class MainWindow : IDisposable private readonly Lock _soundLock = new(); // Window WndProc + private const int WmGetObject = 0x003D; private HwndSource _hwndSource; private int _initialWidth; private int _initialHeight; @@ -595,8 +596,16 @@ private async void OnContextMenusForSettingsClick(object sender, RoutedEventArgs #region Window WndProc + private static bool ShouldSuppressWindowAutomationMessage(int msg) => msg == WmGetObject; + private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) { + if (ShouldSuppressWindowAutomationMessage(msg)) + { + handled = true; + return IntPtr.Zero; + } + switch (msg) { case Win32Helper.WM_ENTERSIZEMOVE: