Closed r2evans closed 4 months ago
It is supposed to be since #180.
Ok, I'll work on a better reproduction, as it is now working (no changes, no restarts), but I know it has not been focused earlier today. Apologize for an incomplete reproduction.
I kind of have a feeling that this is Windows trying to be "smart" and not focus our application even though we requested it. I don't use Windows much but I have noticed that kind of behavior over the years with all applications.
I was thinking the same thing, though I don't have experience programming the Windows-UI side of things. Thanks, I'll report back if I find anything notable.
It's definitely not doing it all of the time: right now, it's always unfocused. It's the same from cmd.exe
or Git bash
(in a mintty), using ssh
or scp
. I can easily bring it into focus (mouse-click, Shift-Alt-Tab, or twice Win-8 (or which ever numbered icon KeePass is on the task bar)).
Is there something I can do to try to figure out what is different about this vice your code's intention? If there's a specific debug-able version of the plugin, I'll run that for you.
Edit: ... and 3 hours later, it's working again. I am not confident that this is entirely/mostly/at-all KeeAgent's fault, frankly: despite my best efforts at maintaining a clean laptop, Windows does at times decide to "be different". Fudge.
It should be pretty easy to clone this repo (git clone --recursive
because of submodules) and run a debug version in Visual Studio if you want to.
Here is the code to look at: https://github.com/dlech/SshAgentLib/commit/844b487b0adeee8d8df777d9395f8dc9432ef2db
I have experienced the same problem "randomly" (it almost always works, but sometimes doesn't) but I haven't found the cause of that "sometimes"
I read somewhere that Windows tries not to give focus to background-started programs, maybe certain level of indirection (git command -> ssh
) causes windows to recognize the window as a background-launched process?
I can confirm that when an ssh
-related processes connects for a key, if KeePass is the focus, then the popup is (so far 100%) in focus as well. When it is a different window (i.e., git bash), it is not so great.
In my on-again/off-again functioning, I'm currently in the "does not focus" mode, and I'm trying changes to window location, stacking order (other than KeePass-in-focus), maximized/visible/minimized, to no avail. However, when I deselect the option "Esc minimizes to tray...", the modal now has focus. @KuttKatrea , next time yours does not gain focus, can you check these settings and see if it changes the behavior?
(Side note: I'm finding that changes to "require user notification" does not always take effect immediately. It's a separate/new issue, but because of this behavior, my routine for trying to reproduce it is: change an option, lock, unlock, use ssh, etc.)
When I reselect those options the popup is still (for now) getting the focus, so perhaps it has something to do with KeePass' "minimization" methods (whether to tray or taskbar, not certain). If what KuttKatrea says (about background-started programs), perhaps the use of the tray may "taint" the program at some point.
(I just updated to win10 1803, no change in behavior from 1709.)
It has just happened to me, when using git in powershell running inside the IntelliJ Terminal.
Changing the "Esc minimizes to tray..." option did work for one git call on a cmd window once, then it stopped working again.
I'll try to keep testing
Similar problems: need to Alt+Shift+Tab
every time the popup shows. If there are 2 consequent popup (ssh client is trying multiple keys), then only first is unfocused, all following would be ok. No difference from what ssh client call happens: Git Bash, WSL Bash, JetBrains DataGrip, Visual Studio Code, Total Commander.
Windows 10 (1809, 17763.316)
KeePass 2.4.1
KeeAgent 0.10.1
As a quick and dirty workaround I use AutoIt script:
While 1
Local $hwnd = WinWait("KeePass", "has requested to use the SSH key")
WinActivate($hwnd)
WEnd
This is still the number one problem in using KeeAgent. There is no apparent logic when the window opens in focus or not focused.
Here is another workaround (since Shift-Alt-Tab is not my favourite key combinations): Press Ctrl-Alt-K (or whatever is your hotkey for "Show KeePass window" in KeePass) and then Esc (to minimize KeePass), then the KeeAgent window gets the focus.
FYI: Now that I've used Windows 11 (build 22000.778, KeePass 2.51.1, KeeAgent 0.12.1) for a few days, my initial experience is that KeeAgent does not suffer from the out-of-focus problem anymore.
I just confirmed that it is still the same. I'm on Win11 (Build 22000.778), KeePass-2.51.1, KeeAgent-0.12.1. The original steps still reproduce the same symptom that the confirmation dialog is not windows-focused when it comes up.
I don't know it that matters but I have the key selection dialog enabled, so it is shown first, and then the confirmation dialog. I configured KeePass and KeeAgent identically on Win10 and Win11.
As a side note, on that new Win11 laptop also Evernote Legacy works better (disclaimer: I'm not endorsing Evernote by any means, on the contrary): new note shortcut opens the note in focus. In general both Win10 (Lenovo X1 Carbon Gen 6) and Win11 (X1C Gen 10) laptops have the same apps installed with the same settings, as far as practically possible. No idea what could have affected these focus issues.
After upgrading Windows 11 to 22H2 (build 22621.900) last week I have started to experience the same out-of-focus problems again. Sigh
FYI, I just merged a PR that changes the UI thread where the confirmation dialog runs. Not sure if it would make a difference in this issue, but if anyone wants to try the build from https://github.com/dlech/KeeAgent/actions/runs/7603541323 and see...
if anyone wants to try the build from https://github.com/dlech/KeeAgent/actions/runs/7603541323 and see...
Tested 1.5 days now: 100% accuracy this far, no focus problems! 💪
Windows 11 22H2 (build 22621.3007)
The key list window opens in the main monitor though (instead of the monitor where the SSH key request was triggered), but I don't know how hard problem that would be to solve.
Looks good based on day 3 with that build!
Any plans to make a release with this feature?
Thanks for the reminder. I just released v0.13.7 so hopefully we can call this issue closed now.
I have selected "Always require user confirmation...". When the popup appears, it is not Windows-focused, which means my normally keyboard-centric workflow is disrupted in order to select the window; at that point, I can left-key or
Alt-Y
my affirmation.Is there a way to force making this popup be the Windows focus?
Reproduction:
ssh
,scp
, orrsync
(not within GfW);KeePass-2.38; KeeAgent-0.10.1.0; Win10pro; GfW-2.17.0