diff --git a/src/AdvancedAutoType.cs b/src/AdvancedAutoType.cs index 2c290f9..9afd290 100644 --- a/src/AdvancedAutoType.cs +++ b/src/AdvancedAutoType.cs @@ -16,6 +16,8 @@ namespace AdvancedAutoType { public sealed class AdvancedAutoTypeExt : Plugin { + private const string m_sIpcEventName_AAT = "advanced-auto-type"; + private const string m_sIpcEventName_UsernameOnly = "auto-type-username"; #region class members private IPluginHost m_host = null; ToolStripMenuItem m_menuItem = null; @@ -83,9 +85,41 @@ public override bool Initialize(IPluginHost host) m_host.MainWindow.FormLoadPost += MainWindow_FormLoadPost; + IpcUtilEx.IpcEvent += OnIpcEvent; + return true; } + private void OnIpcEvent(object sender, IpcEventArgs ipcEventArgs) + { + if (ipcEventArgs.Name.Equals(m_sIpcEventName_AAT, StringComparison.InvariantCultureIgnoreCase)) + { + m_host.MainWindow.BeginInvoke(new Action(Ipc_DoAAT)); + } + if (ipcEventArgs.Name.Equals(m_sIpcEventName_UsernameOnly, StringComparison.InvariantCultureIgnoreCase)) + { + m_host.MainWindow.BeginInvoke(new Action(Ipc_DoUsernameOnly)); + } + } + + private void Ipc_DoAAT() + { + bool bForceAATHotkeyForUnix = Config.AATHotkeyID == 0 && KeePassLib.Native.NativeLib.IsUnix(); + if (bForceAATHotkeyForUnix) Config.AATHotkeyID = -1; + var e = new HotKeyEventArgs(IntPtr.Zero, (IntPtr)Config.AATHotkeyID); + HotKeyPressed(null, e); + if (bForceAATHotkeyForUnix) Config.AATHotkeyID = 0; + } + + private void Ipc_DoUsernameOnly() + { + bool bForceUsernameOnlyHotkeyForUnix = Config.UsernameOnlyHotkeyID == 0 && KeePassLib.Native.NativeLib.IsUnix(); + if (bForceUsernameOnlyHotkeyForUnix) Config.UsernameOnlyHotkeyID = -1; + var e = new HotKeyEventArgs(IntPtr.Zero, (IntPtr)Config.UsernameOnlyHotkeyID); + HotKeyPressed(null, e); + if (bForceUsernameOnlyHotkeyForUnix) Config.UsernameOnlyHotkeyID = 0; + } + private void MainWindow_FormLoadPost(object sender, EventArgs e) { var p = Tools.GetPluginInstance("AlternateAutoType") as Plugin; @@ -107,6 +141,7 @@ private void WndProcHandler(object sender, WndProcEventArgs e) public override void Terminate() { if (m_host == null) return; + IpcUtilEx.IpcEvent -= OnIpcEvent; m_aww.Disable(); WndProcHook.RemoveHandler(m_host.MainWindow); HotkeysDeactivate(); diff --git a/src/Options.Designer.cs b/src/Options.Designer.cs index 4868458..04ad202 100644 --- a/src/Options.Designer.cs +++ b/src/Options.Designer.cs @@ -32,12 +32,9 @@ private void InitializeComponent() { this.cbPWEnter = new System.Windows.Forms.CheckBox(); this.lGATP = new System.Windows.Forms.Label(); - this.tbGAT = new KeePass.UI.HotKeyControlEx(); this.cbPWHotkey = new System.Windows.Forms.ComboBox(); - this.tbPWOnly = new KeePass.UI.HotKeyControlEx(); this.lGAT = new System.Windows.Forms.Label(); this.lAAT = new System.Windows.Forms.Label(); - this.tbAAT = new KeePass.UI.HotKeyControlEx(); this.cbSpecialColumnsRespectPWEnter = new System.Windows.Forms.CheckBox(); this.cbColumnsRememberSort = new System.Windows.Forms.CheckBox(); this.cbExcludeExpiredGroups = new System.Windows.Forms.CheckBox(); @@ -49,17 +46,21 @@ private void InitializeComponent() this.tpAlternateAutotypeHotkeys = new System.Windows.Forms.TabPage(); this.cbUsernameEnter = new System.Windows.Forms.CheckBox(); this.lGATU = new System.Windows.Forms.Label(); - this.tbUsernameOnly = new KeePass.UI.HotKeyControlEx(); this.tpAlternateAutotypeIntegration = new System.Windows.Forms.TabPage(); this.cbDontHidePasswordsWithAsterisk = new System.Windows.Forms.CheckBox(); this.cbSpecialColumnsRespectUsernameEnter = new System.Windows.Forms.CheckBox(); this.cbSearchAsYouType = new System.Windows.Forms.CheckBox(); this.tpAWM = new System.Windows.Forms.TabPage(); - this.textBox1 = new System.Windows.Forms.TextBox(); - this.rbAWMExact = new System.Windows.Forms.RadioButton(); - this.rbAWMStart = new System.Windows.Forms.RadioButton(); - this.rbAWMEnd = new System.Windows.Forms.RadioButton(); this.rbAWMBoth = new System.Windows.Forms.RadioButton(); + this.rbAWMEnd = new System.Windows.Forms.RadioButton(); + this.rbAWMStart = new System.Windows.Forms.RadioButton(); + this.rbAWMExact = new System.Windows.Forms.RadioButton(); + this.textBox1 = new System.Windows.Forms.TextBox(); + this.llHotKeyUnix = new System.Windows.Forms.LinkLabel(); + this.tbUsernameOnly = new KeePass.UI.HotKeyControlEx(); + this.tbGAT = new KeePass.UI.HotKeyControlEx(); + this.tbPWOnly = new KeePass.UI.HotKeyControlEx(); + this.tbAAT = new KeePass.UI.HotKeyControlEx(); this.tcAlternateAutoType.SuspendLayout(); this.tpAlternateAutotypeHotkeys.SuspendLayout(); this.tpAlternateAutotypeIntegration.SuspendLayout(); @@ -89,17 +90,6 @@ private void InitializeComponent() this.lGATP.TabIndex = 13; this.lGATP.Text = "Autotype Password:"; // - // tbGAT - // - this.tbGAT.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.tbGAT.Location = new System.Drawing.Point(507, 43); - this.tbGAT.Margin = new System.Windows.Forms.Padding(5); - this.tbGAT.Name = "tbGAT"; - this.tbGAT.Size = new System.Drawing.Size(439, 38); - this.tbGAT.TabIndex = 10; - this.tbGAT.TabStop = false; - this.tbGAT.TextChanged += new System.EventHandler(this.OnPropagateHotKeys); - // // cbPWHotkey // this.cbPWHotkey.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; @@ -113,16 +103,6 @@ private void InitializeComponent() this.cbPWHotkey.Size = new System.Drawing.Size(369, 39); this.cbPWHotkey.TabIndex = 20; // - // tbPWOnly - // - this.tbPWOnly.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.tbPWOnly.Location = new System.Drawing.Point(507, 107); - this.tbPWOnly.Margin = new System.Windows.Forms.Padding(5); - this.tbPWOnly.Name = "tbPWOnly"; - this.tbPWOnly.Size = new System.Drawing.Size(439, 38); - this.tbPWOnly.TabIndex = 30; - this.tbPWOnly.TextChanged += new System.EventHandler(this.OnPropagateHotKeys); - // // lGAT // this.lGAT.AutoSize = true; @@ -143,15 +123,6 @@ private void InitializeComponent() this.lAAT.TabIndex = 9; this.lAAT.Text = "Alternate AutoType Hotkey:"; // - // tbAAT - // - this.tbAAT.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.tbAAT.Location = new System.Drawing.Point(507, 331); - this.tbAAT.Margin = new System.Windows.Forms.Padding(5); - this.tbAAT.Name = "tbAAT"; - this.tbAAT.Size = new System.Drawing.Size(439, 38); - this.tbAAT.TabIndex = 70; - // // cbSpecialColumnsRespectPWEnter // this.cbSpecialColumnsRespectPWEnter.AutoSize = true; @@ -246,6 +217,7 @@ private void InitializeComponent() // // tpAlternateAutotypeHotkeys // + this.tpAlternateAutotypeHotkeys.Controls.Add(this.llHotKeyUnix); this.tpAlternateAutotypeHotkeys.Controls.Add(this.cbUsernameEnter); this.tpAlternateAutotypeHotkeys.Controls.Add(this.lGATU); this.tpAlternateAutotypeHotkeys.Controls.Add(this.tbUsernameOnly); @@ -261,7 +233,7 @@ private void InitializeComponent() this.tpAlternateAutotypeHotkeys.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.tpAlternateAutotypeHotkeys.Name = "tpAlternateAutotypeHotkeys"; this.tpAlternateAutotypeHotkeys.Padding = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.tpAlternateAutotypeHotkeys.Size = new System.Drawing.Size(985, 648); + this.tpAlternateAutotypeHotkeys.Size = new System.Drawing.Size(985, 592); this.tpAlternateAutotypeHotkeys.TabIndex = 0; this.tpAlternateAutotypeHotkeys.Text = "tabPage1"; this.tpAlternateAutotypeHotkeys.UseVisualStyleBackColor = true; @@ -288,15 +260,6 @@ private void InitializeComponent() this.lGATU.TabIndex = 16; this.lGATU.Text = "Autotype Username:"; // - // tbUsernameOnly - // - this.tbUsernameOnly.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.tbUsernameOnly.Location = new System.Drawing.Point(507, 222); - this.tbUsernameOnly.Margin = new System.Windows.Forms.Padding(5); - this.tbUsernameOnly.Name = "tbUsernameOnly"; - this.tbUsernameOnly.Size = new System.Drawing.Size(439, 38); - this.tbUsernameOnly.TabIndex = 50; - // // tpAlternateAutotypeIntegration // this.tpAlternateAutotypeIntegration.Controls.Add(this.cbDontHidePasswordsWithAsterisk); @@ -365,6 +328,50 @@ private void InitializeComponent() this.tpAWM.Text = "tpAWM"; this.tpAWM.UseVisualStyleBackColor = true; // + // rbAWMBoth + // + this.rbAWMBoth.AutoSize = true; + this.rbAWMBoth.Location = new System.Drawing.Point(21, 416); + this.rbAWMBoth.Name = "rbAWMBoth"; + this.rbAWMBoth.Size = new System.Drawing.Size(204, 36); + this.rbAWMBoth.TabIndex = 98; + this.rbAWMBoth.TabStop = true; + this.rbAWMBoth.Text = "rbAWMBoth"; + this.rbAWMBoth.UseVisualStyleBackColor = true; + // + // rbAWMEnd + // + this.rbAWMEnd.AutoSize = true; + this.rbAWMEnd.Location = new System.Drawing.Point(21, 374); + this.rbAWMEnd.Name = "rbAWMEnd"; + this.rbAWMEnd.Size = new System.Drawing.Size(196, 36); + this.rbAWMEnd.TabIndex = 97; + this.rbAWMEnd.TabStop = true; + this.rbAWMEnd.Text = "rbAWMEnd"; + this.rbAWMEnd.UseVisualStyleBackColor = true; + // + // rbAWMStart + // + this.rbAWMStart.AutoSize = true; + this.rbAWMStart.Location = new System.Drawing.Point(21, 332); + this.rbAWMStart.Name = "rbAWMStart"; + this.rbAWMStart.Size = new System.Drawing.Size(205, 36); + this.rbAWMStart.TabIndex = 96; + this.rbAWMStart.TabStop = true; + this.rbAWMStart.Text = "rbAWMStart"; + this.rbAWMStart.UseVisualStyleBackColor = true; + // + // rbAWMExact + // + this.rbAWMExact.AutoSize = true; + this.rbAWMExact.Location = new System.Drawing.Point(21, 290); + this.rbAWMExact.Name = "rbAWMExact"; + this.rbAWMExact.Size = new System.Drawing.Size(216, 36); + this.rbAWMExact.TabIndex = 95; + this.rbAWMExact.TabStop = true; + this.rbAWMExact.Text = "rbAWMExact"; + this.rbAWMExact.UseVisualStyleBackColor = true; + // // textBox1 // this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) @@ -378,49 +385,55 @@ private void InitializeComponent() this.textBox1.Size = new System.Drawing.Size(940, 242); this.textBox1.TabIndex = 94; // - // radioButton1 + // llHotKeyUnix // - this.rbAWMExact.AutoSize = true; - this.rbAWMExact.Location = new System.Drawing.Point(21, 290); - this.rbAWMExact.Name = "radioButton1"; - this.rbAWMExact.Size = new System.Drawing.Size(216, 36); - this.rbAWMExact.TabIndex = 95; - this.rbAWMExact.TabStop = true; - this.rbAWMExact.Text = "rbAWMExact"; - this.rbAWMExact.UseVisualStyleBackColor = true; + this.llHotKeyUnix.AutoSize = true; + this.llHotKeyUnix.Location = new System.Drawing.Point(32, 393); + this.llHotKeyUnix.Name = "llHotKeyUnix"; + this.llHotKeyUnix.Size = new System.Drawing.Size(179, 32); + this.llHotKeyUnix.TabIndex = 71; + this.llHotKeyUnix.TabStop = true; + this.llHotKeyUnix.Text = "llHotKeyUnix"; + this.llHotKeyUnix.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.llHotKeyUnix_LinkClicked); // - // radioButton2 + // tbUsernameOnly // - this.rbAWMStart.AutoSize = true; - this.rbAWMStart.Location = new System.Drawing.Point(21, 332); - this.rbAWMStart.Name = "radioButton2"; - this.rbAWMStart.Size = new System.Drawing.Size(205, 36); - this.rbAWMStart.TabIndex = 96; - this.rbAWMStart.TabStop = true; - this.rbAWMStart.Text = "rbAWMStart"; - this.rbAWMStart.UseVisualStyleBackColor = true; + this.tbUsernameOnly.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.tbUsernameOnly.Location = new System.Drawing.Point(507, 222); + this.tbUsernameOnly.Margin = new System.Windows.Forms.Padding(5); + this.tbUsernameOnly.Name = "tbUsernameOnly"; + this.tbUsernameOnly.Size = new System.Drawing.Size(439, 38); + this.tbUsernameOnly.TabIndex = 50; // - // radioButton3 + // tbGAT // - this.rbAWMEnd.AutoSize = true; - this.rbAWMEnd.Location = new System.Drawing.Point(21, 374); - this.rbAWMEnd.Name = "radioButton3"; - this.rbAWMEnd.Size = new System.Drawing.Size(196, 36); - this.rbAWMEnd.TabIndex = 97; - this.rbAWMEnd.TabStop = true; - this.rbAWMEnd.Text = "rbAWMEnd"; - this.rbAWMEnd.UseVisualStyleBackColor = true; + this.tbGAT.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.tbGAT.Location = new System.Drawing.Point(507, 43); + this.tbGAT.Margin = new System.Windows.Forms.Padding(5); + this.tbGAT.Name = "tbGAT"; + this.tbGAT.Size = new System.Drawing.Size(439, 38); + this.tbGAT.TabIndex = 10; + this.tbGAT.TabStop = false; + this.tbGAT.TextChanged += new System.EventHandler(this.OnPropagateHotKeys); // - // radioButton4 + // tbPWOnly // - this.rbAWMBoth.AutoSize = true; - this.rbAWMBoth.Location = new System.Drawing.Point(21, 416); - this.rbAWMBoth.Name = "radioButton4"; - this.rbAWMBoth.Size = new System.Drawing.Size(204, 36); - this.rbAWMBoth.TabIndex = 98; - this.rbAWMBoth.TabStop = true; - this.rbAWMBoth.Text = "rbAWMBoth"; - this.rbAWMBoth.UseVisualStyleBackColor = true; + this.tbPWOnly.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.tbPWOnly.Location = new System.Drawing.Point(507, 107); + this.tbPWOnly.Margin = new System.Windows.Forms.Padding(5); + this.tbPWOnly.Name = "tbPWOnly"; + this.tbPWOnly.Size = new System.Drawing.Size(439, 38); + this.tbPWOnly.TabIndex = 30; + this.tbPWOnly.TextChanged += new System.EventHandler(this.OnPropagateHotKeys); + // + // tbAAT + // + this.tbAAT.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.tbAAT.Location = new System.Drawing.Point(507, 331); + this.tbAAT.Margin = new System.Windows.Forms.Padding(5); + this.tbAAT.Name = "tbAAT"; + this.tbAAT.Size = new System.Drawing.Size(439, 38); + this.tbAAT.TabIndex = 70; // // Options // @@ -474,5 +487,6 @@ private void InitializeComponent() internal System.Windows.Forms.RadioButton rbAWMBoth; internal System.Windows.Forms.RadioButton rbAWMEnd; internal System.Windows.Forms.RadioButton rbAWMStart; - } + private System.Windows.Forms.LinkLabel llHotKeyUnix; + } } \ No newline at end of file diff --git a/src/Options.cs b/src/Options.cs index d99bb0f..39af5cc 100644 --- a/src/Options.cs +++ b/src/Options.cs @@ -105,7 +105,15 @@ private void cbSpecialColumns_CheckedChanged(object sender, System.EventArgs e) private void Options_Load(object sender, System.EventArgs e) { - tpAlternateAutotypeHotkeys.Enabled = !KeePassLib.Native.NativeLib.IsUnix(); + if (KeePassLib.Native.NativeLib.IsUnix()) + { + foreach(Control c in tpAlternateAutotypeHotkeys.Controls) + { + if (c == cbUsernameEnter || c == llHotKeyUnix) continue; + c.Enabled = false; + } + } + //tpAlternateAutotypeHotkeys.Enabled = !KeePassLib.Native.NativeLib.IsUnix(); if (!tpAlternateAutotypeHotkeys.Enabled) tcAlternateAutoType.SelectedTab = tpAlternateAutotypeIntegration; cbSpecialColumns_CheckedChanged(null, null); } @@ -120,6 +128,14 @@ internal void OptionsForm_Shown(object sender, EventArgs e) //Move all controls from UserControl in TabPage to TabPage //Make UserControl invisible (do NOT remove: OptionsForm_Closed won't work otherwise) m_ParentForm = ParentForm; + + llHotKeyUnix.Visible = KeePassLib.Native.NativeLib.IsUnix(); + llHotKeyUnix.Links.Clear(); + Control m_linkHotKeyHelp = Tools.GetControl("m_linkHotKeyHelp", m_ParentForm); + string sText = m_linkHotKeyHelp != null ? m_linkHotKeyHelp.Text : "Create system-wide hot keys"; + llHotKeyUnix.Links.Add(0, sText.Length); + llHotKeyUnix.Text = sText; + while (Controls.Count > 0) Parent.Controls.Add(Controls[0]); Height = Width = 0; Visible = false; @@ -164,5 +180,10 @@ private void cbKeepATOpen_CheckedChanged(object sender, EventArgs e) { if (cbKeepATOpen.Checked) cbSpecialColumns.Checked = true; } + + private void llHotKeyUnix_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) + { + Tools.OpenUrl("https://github.com/Rookiestyle/AdvancedAutoType/wiki/Unix-Linux-%E2%80%90-Create-system%E2%80%90wide-hot-keys"); + } } } diff --git a/src/Properties/AssemblyInfo.cs b/src/Properties/AssemblyInfo.cs index 5661126..d73c76d 100644 --- a/src/Properties/AssemblyInfo.cs +++ b/src/Properties/AssemblyInfo.cs @@ -15,7 +15,7 @@ KeePass types EITHER everything before OR everything after {AAT}. [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("rookiestyle")] [assembly: AssemblyProduct("KeePass Plugin")] -[assembly: AssemblyCopyright("Copyright 2020-2023")] +[assembly: AssemblyCopyright("Copyright 2020-2024")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // This sets the default COM visibility of types in the assembly to invisible. @@ -27,7 +27,7 @@ KeePass types EITHER everything before OR everything after {AAT}. // // You can specify all the values or you can use the default the Revision and // Build Numbers by using the '*' as shown below: -[assembly: AssemblyVersion("2.1.2")] -[assembly: AssemblyFileVersion("2.1.2")] +[assembly: AssemblyVersion("2.2")] +[assembly: AssemblyFileVersion("2.2")] [assembly: Guid("78C152F3-EAF8-4FFC-9BE3-F5DC0CD66E5D")] diff --git a/version.info b/version.info index 4889b6b..cd5ccea 100644 --- a/version.info +++ b/version.info @@ -1,6 +1,6 @@ : AlternateAutoType:1.20 -Advanced Auto-Type:2.1.2 +Advanced Auto-Type:2.2 Advanced Auto-Type!de:8 Advanced Auto-Type!pt:4 Advanced Auto-Type!ru:5