using System; using System.Collections.Generic; using System.Text; using KeePass.Plugins; using KeePass.Util; using System.Diagnostics; using System.Runtime.InteropServices; namespace NeoWorkaround { public class NeoWorkaroundExt : Plugin { [DllImport("user32.dll")] private static extern uint RegisterWindowMessage(string lpString); [DllImport("user32.dll")] private static extern IntPtr SendMessage( IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam ); public override bool Initialize(IPluginHost host) { AutoType.FilterSendPre += AutoType_FilterSendPre; return true; } public override void Terminate() { AutoType.FilterSendPre -= AutoType_FilterSendPre; } private void AutoType_FilterSendPre(object sender, AutoTypeEventArgs e) { var oldHandler = e.Entry.Touched; /* It's a hack. There is no event that occurs AFTER the AutoType * event. But the entry that is being typed is touched afterwards, * to update the internal last update time. The touched event is * raised at that point and this code exploits that event to enable * the NEO layout again. */ e.Entry.Touched = (touchedSender, touchedE) => { uint enableMsgId = RegisterWindowMessage("NEO_ENABLE"); SendMessage( new IntPtr(0xffff), enableMsgId, IntPtr.Zero, IntPtr.Zero ); /* Call the existing handler. */ if (oldHandler != null) { oldHandler(touchedSender, touchedE); } /* Restore the existing handler. */ e.Entry.Touched = oldHandler; }; uint disableMsgId = RegisterWindowMessage("NEO_DISABLE"); SendMessage( new IntPtr(0xffff), disableMsgId, IntPtr.Zero, IntPtr.Zero ); } } }