KeePassWinHello
KeePassWinHello copied to clipboard
Windows Hello window not in focus when KeePass opened through a shortcut
Describe the bug
When opening KeePas from locked state via a shortcut (Ctrl+Alt+A in my case), resulting Windows Hello window is not in foreground and does not have focus on it. This causes reading fingerprint to fail until I manualy select Windows Hello window to make it in focus.
To Reproduce
Steps to reproduce the behavior:
- Lock KeePass database, so accessing it requires authentication.
- Open any aplication that has autofill enabled.
- Use autofill shortcut.
- Resulting Windows Hello window is in background and not in focus.
Expected behavior
Windows Hello window must be on top and in focus.
Screenshots
Windows Hello window opened in background and not in focus.

Context
| Component | Version |
|---|---|
| Operating System | Windows 10 Pro 10.0.19041 |
| KeePass | 2.50 |
| Plugin | 3.2 |
Hardware info
- Motherboard: Asus TUF Gaming B450M-PRO II
- DigitalPersona U.are.U 4500
- TPM module info None (No module found)
Plugin settings
- [X] Is persistent mode enabled ("Store keys in Windows Credential Manager" checked)
- [X] Results are the same if persistent mode is disabled
KeePass settings and environment
- [ ] Is secure desktop enabled
- [ ] Is KeePass running under Administrator (in elevated process)
- [ ] Was it right after hibernation
- [X] Was KeePass minified or closed
- [X] No additional plugins installed
Additional context
If I open KeePass application, Windows Hello window is in foreground and in focus as expected. But the same does not happen when KeePass is opened through a shortcut.
The same applies when using KeeAgent Plugin. If you start a SSH connection while KeePass is locked, SSH seems to hang. Meanwhile the WinHello Prompt is waiting hidden behind the Terminal window.
As it turns out, KeepassXC has windows hello feature built-in. So if you are not tied to strictly using regular KeePass, than I would recommend switching over to KeepassXC.
It would really be great to have this fixed.
I also have this issue (KeePass 2.51.1 64Bit and KeePassWinHello 3.2). I recently noted that it doesn't occur when I'm entering my hot key for "show KeePass window":
- hot key "Global auto-type": The WinHello-Prompt doesn't get the focus and is somewhere in the background
- hot key "show KeePass window": The WinHello-Prompt is in front and everything works like a charme...
Maybe this helps for locating the problem in the code. Because the issue is quite annoying it would be great to get this fixed soon! Thank you!!
I did some research and may have approached the problem. I found these lines in the Code of the main KeePass Software (v 2.53):
KeePass: MainForm_Functions.cs - line 2962:
internal void HandleHotKey(int wParam)
{
if(HotKeyManager.HandleHotKeyIntoSelf(wParam)) return;
if(wParam == AppDefs.GlobalHotKeyId.AutoType)
ExecuteGlobalAutoType();
else if(wParam == AppDefs.GlobalHotKeyId.AutoTypePassword)
ExecuteGlobalAutoType(@"{PASSWORD}");
else if(wParam == AppDefs.GlobalHotKeyId.AutoTypeSelected)
ExecuteEntryAutoType();
else if(wParam == AppDefs.GlobalHotKeyId.ShowWindow)
{
bool bWndVisible = ((this.WindowState != FormWindowState.Minimized) &&
!IsTrayed());
EnsureVisibleForegroundWindow(true, true);
if(bWndVisible && IsFileLocked(null))
OnFileLock(null, EventArgs.Empty); // Unlock
}
else if(wParam == AppDefs.GlobalHotKeyId.EntryMenu)
EntryMenu.Show();
else { Debug.Assert(false); }
}
So only for the ShowWindow-Command the visibility check is done. This makes sense in all normal cases but with WinHello it causes the stated problem I guess.
I don't know if there is a possibility to bring the Windows Hello form to the front from inside the WinHello-Code or if we have to jump over to the KeePass Bug report area. Could please someone with more experience comment on that? Thanks for helping out!
I always get the PIN entry window from Windows Hello in the foreground, but after completing this, the account selection window from KeePass is in the background. So still a window focus issue, but at another time.
I just set up my new Laptop with fingerprint sensor and would love to use this to unlock KeePass. But with this focus bug its annoying.
Any update on this? Did or can some one investigate this further?
No, lost interest because it works much better with KeePassXC.
related: #25