diff --git a/LittleWarGameClient/GameForm.cs b/LittleWarGameClient/GameForm.cs index 7c8a277..d09aa0f 100644 --- a/LittleWarGameClient/GameForm.cs +++ b/LittleWarGameClient/GameForm.cs @@ -238,7 +238,9 @@ private void GameForm_Activated(object sender, EventArgs e) { CaptureCursor(); ResizeGameWindows(); - SendKeys.Send("%{F16}"); //Alt-Tab fix for game + if (kbHandler.hasHangingAltKey) //Alt-Tab fix for game + SendKeys.Send("%{F16}"); + if (!OverlayForm.Instance.IsDisposed) OverlayForm.Instance.Visible = true; } diff --git a/LittleWarGameClient/KeyboardHandler.cs b/LittleWarGameClient/KeyboardHandler.cs index a21741d..7a1f208 100644 --- a/LittleWarGameClient/KeyboardHandler.cs +++ b/LittleWarGameClient/KeyboardHandler.cs @@ -9,6 +9,7 @@ namespace LittleWarGameClient internal class KeyboardHandler : IKeyboardHandler { private readonly Dictionary hotKeys = new Dictionary(); + internal bool hasHangingAltKey = false; internal KeyboardHandler(Settings settings) { @@ -84,6 +85,11 @@ public bool OnPreKeyEvent(IWebBrowser webView, IBrowser browser, KeyType type, i return true; var key = (Keys)windowsKeyCode; + if (type == KeyType.KeyUp) + { + if (key == Keys.Menu) // Alt key + hasHangingAltKey = false; + } if (type == KeyType.RawKeyDown) { #if DEBUG @@ -93,6 +99,9 @@ public bool OnPreKeyEvent(IWebBrowser webView, IBrowser browser, KeyType type, i return true; } #endif + if (key == Keys.Menu) // Alt key + hasHangingAltKey = true; + if (hotKeys.ContainsKey(key)) { var funcToCall = hotKeys[key]; @@ -106,6 +115,10 @@ public bool OnPreKeyEvent(IWebBrowser webView, IBrowser browser, KeyType type, i public bool OnKeyEvent(IWebBrowser webView, IBrowser browser, KeyType type, int windowsKeyCode, int nativeKeyCode, CefEventFlags modifiers, bool isSystemKey) { + if (isSystemKey && type == KeyType.Char) + return true; + if (windowsKeyCode == 0x7F && modifiers == CefEventFlags.AltDown) + hasHangingAltKey = false; return false; } } diff --git a/LittleWarGameClient/js/lwg-5.0.0.js b/LittleWarGameClient/js/lwg-5.0.0.js index e401a6e..aa81bd2 100644 --- a/LittleWarGameClient/js/lwg-5.0.0.js +++ b/LittleWarGameClient/js/lwg-5.0.0.js @@ -25902,7 +25902,9 @@ var globalLWGDebug = false; } } for (const k of unitsToRemove) { - keyManager.controlGroups[j].splice(k, 1); + if (j != nr) { + keyManager.controlGroups[j].splice(k, 1); + } } } }