Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions src/KeePassWinHelloExt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Diagnostics;
using System.Drawing;
using System.Reflection;
using System.Windows.Forms;
using KeePass.Forms;
using KeePass.Plugins;
using KeePass.UI;
Expand Down Expand Up @@ -113,6 +114,13 @@ private void OnWindowAdded(object sender, GwmWindowEventArgs e)
}
}

var autoTypeCtxForm = e.Form as AutoTypeCtxForm;
if (autoTypeCtxForm != null)
{
BringAutoTypeSelectionToFront(autoTypeCtxForm);
return;
}

var optionsForm = e.Form as OptionsForm;
if (optionsForm != null)
{
Expand All @@ -129,5 +137,44 @@ private void OnWindowAdded(object sender, GwmWindowEventArgs e)
_uiContextManager.CurrentContext.ShowError(ex);
}
}

private static void BringAutoTypeSelectionToFront(AutoTypeCtxForm autoTypeCtxForm)
{
try
{
autoTypeCtxForm.BeginInvoke(new MethodInvoker(delegate
{
try
{
if (autoTypeCtxForm.IsDisposed)
return;

var window = Win32Window.From(autoTypeCtxForm.Handle);
if (window != null)
window.EnsureForeground();

bool topMost = autoTypeCtxForm.TopMost;
try
{
autoTypeCtxForm.TopMost = true;
autoTypeCtxForm.BringToFront();
autoTypeCtxForm.Activate();
}
finally
{
autoTypeCtxForm.TopMost = topMost;
}
}
catch (Exception ex)
{
Debug.Fail(ex.Message);
}
}));
}
catch (Exception ex)
{
Debug.Fail(ex.Message);
}
}
}
}