KeePass is a "free, open source, light-weight and easy-to-use password manager."
MinLock is a simple plugin for KeePass 2.x that keeps a minimized KeePass locked (re-locks almost immediately after it becomes unlocked, so long as it is still minimized).
This happens to be the case when KeePass is locked and minimized and then it's global auto-type feature is used, which can unlock KeePass and leave it unlocked.
To run, just download and extract the PLGX Plugin to your KeePass directory.
KeePass has a short page about plugin development for version 2.x here.
KeePass does have auto-lock features based on timers (e.g. idle time) that can achieve close to this but not quite as well.
Using the code
The small VS.NET solution is available (you'll have to fix the reference to KeePass.exe).
Here's the full MinLock plugin class:
public sealed class MinLockExt : Plugin
public override bool Initialize(IPluginHost host)
m_Host = host;
m_Host.MainWindow.FileOpened += MainWindow_FileOpened;
public override void Terminate()
if (m_Timer != null)
m_Timer = null;
void MainWindow_FileOpened(object sender, KeePass.Forms.FileOpenedEventArgs e)
if (m_Timer == null && m_Host.MainWindow.WindowState == FormWindowState.Minimized)
m_Timer = new Timer();
m_Timer.Interval = 1;
m_Timer.Tick += Timer_Tick;
void Timer_Tick(object sender, EventArgs e)
if (m_Host.MainWindow.WindowState == FormWindowState.Minimized &&
This plugin simply responds to a file being opened (which for KeePass, my understanding is that this is only when it has opened its secure database file). Then KeePass has some things to finishing doing in the current callstack. Instead of locking in the FileOpened event handler, I do a bit of hackery and use a Windows.Forms.Timer to wait just a bit before re-locking the KeePass workspace. The timer can't fire until the underlying message pump runs, so in this way the plugin doesn't interrupt KeePass in the same callstack of the event firing. KeePass continues on merrily, appears to do all it needs to do with the database, and then very shortly afterwards the message pump runs, the timer tick event fires, and MinLock re-locks KeePass
MinLock was developed with KeePass version 2.19. See the plugin development page for details about PLGX compatibility with future versions of KeePass.
Points of Interest
This approach turned out pretty well because MinLock re-locks KeePass before it even finishes auto-typing.
KeePass plugins are cake.
This might be better off as an official KeePass option-based feature instead of a plugin.
MinLock does break one minor feature of KeePass. If KeePass is minimized and locked, the user can right-click the tray icon and select "Unlock Workspace". That feature of KeePass does not restore the KeePass Password Safe window, so almost instantly after unlocking the plugin will re-lock KeePass. There are at least 3 other ways to unlock a minimized-and-locked KeePass that don't have this issue (because they all restore the KeePass window before presenting the unlock dialog); so use one of these instead: 1) double click the tray icon, 2) tray icon --> "Tray / Untray", 3) Crtl + Alt + K (default hotkey to show KeePass window).
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.