diff --git a/src/RemSound.App/KeyClickService.cs b/src/RemSound.App/KeyClickService.cs index 1fad0b1..8fb9ba7 100644 --- a/src/RemSound.App/KeyClickService.cs +++ b/src/RemSound.App/KeyClickService.cs @@ -20,6 +20,12 @@ internal static class KeyClickService { private const int WM_CHAR = 0x0102; + /// Tag value a password entry field sets on itself (control.Tag = PasswordFieldTag) + /// so the key-click hook layers in the distinct passkey sound. RemSound's password boxes are + /// deliberately NOT PasswordChar-masked (a screen-reader user can't see the mask anyway), so + /// there's no built-in flag to detect - they mark themselves with this tag instead. + public const string PasswordFieldTag = "remsound-password-field"; + private static KeyClickPlayer? player; private static MessageFilter? filter; @@ -58,7 +64,10 @@ internal static class KeyClickService if (!Enabled || player is null) return; // The WM_CHAR target window is the focused control. Click only when it's an edit field. if (System.Windows.Forms.Control.FromHandle(hwnd) is not System.Windows.Forms.TextBoxBase edit) return; - var isPassword = edit is System.Windows.Forms.TextBox tb && (tb.UseSystemPasswordChar || tb.PasswordChar != '\0'); + // A password field is marked by its Tag (RemSound's boxes aren't PasswordChar-masked), with + // a fallback to the standard masking flags for any conventionally-masked box. + var isPassword = (edit.Tag as string) == PasswordFieldTag + || (edit is System.Windows.Forms.TextBox tb && (tb.UseSystemPasswordChar || tb.PasswordChar != '\0')); player.PlayClick(isPassword); } diff --git a/src/RemSound.App/ProfilePasswordDialog.cs b/src/RemSound.App/ProfilePasswordDialog.cs index dc4d9c2..08e22ea 100644 --- a/src/RemSound.App/ProfilePasswordDialog.cs +++ b/src/RemSound.App/ProfilePasswordDialog.cs @@ -38,6 +38,8 @@ internal static class ProfilePasswordDialog Dock = DockStyle.Top, Width = 400, AccessibleName = $"Password for profile {profileTitle}", + // Mark as a password field so the key-click hook layers in the passkey sound. + Tag = KeyClickService.PasswordFieldTag, }; var hint = new Label { diff --git a/src/RemSound.App/ProfilePasswordManagerDialog.cs b/src/RemSound.App/ProfilePasswordManagerDialog.cs index fe6a851..497465b 100644 --- a/src/RemSound.App/ProfilePasswordManagerDialog.cs +++ b/src/RemSound.App/ProfilePasswordManagerDialog.cs @@ -60,7 +60,7 @@ internal static class ProfilePasswordManagerDialog catch { current = ""; } var label = new Label { Text = title, AutoSize = true, Anchor = AnchorStyles.Left, Padding = new Padding(0, 6, 10, 6) }; - var box = new TextBox { Text = current, Anchor = AnchorStyles.Left | AnchorStyles.Right, AccessibleName = $"Password for profile {title}" }; + var box = new TextBox { Text = current, Anchor = AnchorStyles.Left | AnchorStyles.Right, AccessibleName = $"Password for profile {title}", Tag = KeyClickService.PasswordFieldTag }; grid.Controls.Add(label); grid.Controls.Add(box); rows.Add((title, current, box));