From 0574ab383f82425cbacb413ba9f54bd09954d3c3 Mon Sep 17 00:00:00 2001 From: Alexis Date: Sat, 8 Feb 2020 19:09:19 +0100 Subject: [PATCH] - Improved KeyboardHook logging --- .../Services/IO/Keyboard/KeyboardHook.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Core/SuperMemoAssistant.Interop/Services/IO/Keyboard/KeyboardHook.cs b/src/Core/SuperMemoAssistant.Interop/Services/IO/Keyboard/KeyboardHook.cs index 52bf491..161b9e5 100644 --- a/src/Core/SuperMemoAssistant.Interop/Services/IO/Keyboard/KeyboardHook.cs +++ b/src/Core/SuperMemoAssistant.Interop/Services/IO/Keyboard/KeyboardHook.cs @@ -224,6 +224,19 @@ private IntPtr LowLevelKeyboardProc(int nCode, { scopeMatches = false; } + + // ReSharper disable once ConditionIsAlwaysTrueOrFalse + else if (_elWdwHandle == null || _elWdwHandle == IntPtr.Zero) + { + LogTo.Warning( + $"KeyboardHook: HotKey {hk} requested with scope {Enum.GetName(typeof(HotKeyScope), hkReg.Scope)}, but _elWdwHandle is {foregroundWdwHandle}. Trying to refresh."); + + OnElementWindowAvailable(); + + // ReSharper disable once ConditionIsAlwaysTrueOrFalse + if (_elWdwHandle == null || _elWdwHandle == IntPtr.Zero) + scopeMatches = false; + } else if (hkReg.Scope == HotKeyScope.SMBrowser && foregroundWdwHandle != _elWdwHandle) {