private void PrepareSend() { IntPtr hWnd = NativeMethods.GetForegroundWindowHandle(); m_swiCurrent = GetWindowInfo(hWnd); EnsureSameKeyboardLayout(); }
private SiSendMethod GetSendMethod(SiWindowInfo swi) { if (m_osmEnforced.HasValue) { return(m_osmEnforced.Value); } return(swi.SendMethod); }
private SiWindowInfo GetWindowInfo(IntPtr hWnd) { SiWindowInfo swi; if (m_dWindowInfos.TryGetValue(hWnd, out swi)) { return(swi); } swi = new SiWindowInfo(hWnd); Process p = null; try { uint uPID; uint uTID = NativeMethods.GetWindowThreadProcessId(hWnd, out uPID); swi.KeyboardLayout = NativeMethods.GetKeyboardLayout(uTID); p = Process.GetProcessById((int)uPID); string strName = GetProcessName(p); foreach (KeyValuePair <string, SiSendMethod> kvp in g_dProcessSendMethods) { if (ProcessNameMatches(strName, kvp.Key)) { swi.SendMethod = kvp.Value; break; } } // The workaround attempt for Edge below doesn't work; // Edge simply ignores Unicode packets for '@', Euro sign, etc. /* if(swi.SendMethod == SiSendMethod.Default) * { * string strTitle = NativeMethods.GetWindowText(hWnd, true); * * // Workaround for Edge; * // https://sourceforge.net/p/keepass/discussion/329220/thread/fd3a6776/ * // The window title is: * // Page name + Space + U+200E (left-to-right mark) + "- Microsoft Edge" * if(strTitle.EndsWith("- Microsoft Edge", StrUtil.CaseIgnoreCmp)) * swi.SendMethod = SiSendMethod.UnicodePacket; * } */ } catch (Exception) { Debug.Assert(false); } finally { try { if (p != null) { p.Dispose(); } } catch (Exception) { Debug.Assert(false); } } m_dWindowInfos[hWnd] = swi; return(swi); }