private void AddToAutotype(string s) { if (string.IsNullOrEmpty(s)) { return; } int i = 0; AWMDuplicateHandling dup = AWMDuplicateHandling.Undefined; bool bShift = (Control.ModifierKeys & Keys.Shift) == Keys.Shift; foreach (var pe in KeePass.Program.MainForm.GetSelectedEntries()) { if (AddToAutotype(pe, s, ref dup)) { i++; } } if (i > 0) { Tools.RefreshEntriesList(true); } if ((dup == AWMDuplicateHandling.Edit || bShift) && m_miEditSelectedEntry != null) { m_sAddedWindowText = s; if (Tools.KeePassVersion < new Version(2, 49)) { m_miEditSelectedEntry.Invoke(KeePass.Program.MainForm, new object[] { false }); } else { m_miEditSelectedEntry.Invoke(KeePass.Program.MainForm, new object[] { 0 }); } } }
private bool AddToAutotype(PwEntry pe, string s, ref AWMDuplicateHandling dup) { if (pe.AutoType.Associations.FirstOrDefault(x => string.Compare(x.WindowName, s, true) == 0) != null) { if (dup == AWMDuplicateHandling.Undefined) { dup = GetDuplicateHandling(s); } if (dup != AWMDuplicateHandling.Add) { return(false); } } pe.CreateBackup(KeePass.Program.MainForm.DocumentManager.SafeFindContainerOf(pe)); pe.AutoType.Add(new KeePassLib.Collections.AutoTypeAssociation(s, string.Empty)); pe.Touch(true, false); return(true); }