sirAndros / KeePassWinHello

Quick unlock KeePass 2 database using biometrics with Windows Hello
MIT License
302 stars 21 forks source link

Windows Hello window not in focus when KeePass opened through a shortcut #86

Open c0m1c5an5 opened 2 years ago

c0m1c5an5 commented 2 years ago

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:

  1. Lock KeePass database, so accessing it requires authentication.
  2. Open any aplication that has autofill enabled.
  3. Use autofill shortcut.
  4. 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.

screenshot

Context

Component Version
Operating System Windows 10 Pro 10.0.19041
KeePass 2.50
Plugin 3.2

Hardware info

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.

SteveDax commented 2 years ago

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.

c0m1c5an5 commented 2 years ago

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.

me4175 commented 1 year ago

It would really be great to have this fixed.

Bilemma commented 1 year ago

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":

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!!

Bilemma commented 1 year ago

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!

ygoe commented 1 year ago

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.

loeffelpan commented 7 months ago

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?

ygoe commented 7 months ago

No, lost interest because it works much better with KeePassXC.

sirAndros commented 3 months ago

related: #25