@@ -40,6 +40,11 @@ private bool PWOnlyHotkeyPressed
4040 {
4141 get { return ( m_bKPAutoTypePasswordHotkey || ( m_sequence != 0 ) && ( m_sequence == Config . PWOnlyHotkeyID ) ) ; }
4242 }
43+
44+ private bool UsernameOnlyHotkeyPressed
45+ {
46+ get { return ( m_sequence != 0 ) && ( m_sequence == Config . UsernameOnlyHotkeyID ) ; }
47+ }
4348 #endregion
4449
4550 public override bool Initialize ( IPluginHost host )
@@ -112,13 +117,16 @@ private string AdjustSequence(string sequence, bool bResetPWOnly)
112117 {
113118 /*
114119 * Option 1: Hotkey for password only is used => return {PASSWORD}
115- * Option 2: No placeholder => nothing to do
116- * Option 3: Placeholder and hotkey for AAT is used => return sequence part AFTER placeholder
117- * Option 4: Placeholder and hotkey for AAT is not used => return sequence part BEFORE placeholder
120+ * Option 2: Hotkey for username only is used => return {USERNAME}
121+ * Option 3: No placeholder => nothing to do
122+ * Option 4: Placeholder and hotkey for AAT is used => return sequence part AFTER placeholder
123+ * Option 5: Placeholder and hotkey for AAT is not used => return sequence part BEFORE placeholder
118124 */
119125 bool bPWOnly = PWOnlyHotkeyPressed ;
120126 if ( bResetPWOnly ) CheckKPAutoTypePasswordHotkey ( false ) ;
121- if ( bPWOnly && Config . PWEnter ) return sequence + "{ENTER}" ;
127+ if ( bPWOnly ) return "{PASSWORD}" + ( Config . PWEnter ? "{ENTER}" : string . Empty ) ;
128+ if ( UsernameOnlyHotkeyPressed ) return "{USERNAME}" + ( Config . UsernameOnlyEnter ? "{ENTER}" : string . Empty ) ;
129+
122130 int pos = sequence . IndexOf ( Config . Placeholder ) ;
123131 if ( pos < 0 ) return sequence ;
124132 if ( AATHotkeyPressed )
@@ -149,6 +157,7 @@ private void HotKeyPressed(object sender, HotKeyEventArgs e)
149157 lMsg . Add ( "Hotkey id: " + m_sequence . ToString ( ) ) ;
150158 lMsg . Add ( "PW only hotkey: " + Config . PWOnlyHotkeyID . ToString ( ) + " - " + ( Config . PWOnlyHotkeyID == e . ID ) . ToString ( ) ) ;
151159 lMsg . Add ( "AAT only hotkey: " + Config . AATHotkeyID + " - " + ( Config . AATHotkeyID == e . ID ) . ToString ( ) ) ;
160+ lMsg . Add ( "Username only hotkey: " + Config . UsernameOnlyHotkeyID + " - " + ( Config . UsernameOnlyHotkeyID == e . ID ) . ToString ( ) ) ;
152161 PluginDebug . AddInfo ( "Alternate Auto-Type hotkey detected" , 0 , lMsg . ToArray ( ) ) ;
153162 m_host . MainWindow . ExecuteGlobalAutoType ( ) ;
154163 m_sequence = 0 ;
@@ -170,6 +179,12 @@ private void HotkeysActivate()
170179 if ( Config . PWOnlyHotkeyID == 0 )
171180 Tools . ShowError ( string . Format ( PluginTranslate . ErrorHotKeyPWOnly , Config . PWOnlyHotkey . ToString ( ) ) ) ;
172181 }
182+ if ( Config . UsernameOnlyHotkey != Keys . None )
183+ {
184+ Config . UsernameOnlyHotkeyID = PTHotKeyManager . RegisterHotKey ( Config . UsernameOnlyHotkey ) ;
185+ if ( Config . UsernameOnlyHotkeyID == 0 )
186+ Tools . ShowError ( string . Format ( PluginTranslate . ErrorHotKeyUsernameOnly , Config . UsernameOnlyHotkey . ToString ( ) ) ) ;
187+ }
173188 }
174189
175190 private void HotkeysDeactivate ( )
@@ -179,6 +194,8 @@ private void HotkeysDeactivate()
179194 PTHotKeyManager . UnregisterHotKey ( Config . AATHotkeyID ) ;
180195 if ( ( Config . PWOnlyHotkey != Keys . None ) && ! Config . KPAutoTypePWPossible )
181196 PTHotKeyManager . UnregisterHotKey ( Config . PWOnlyHotkeyID ) ;
197+ if ( Config . UsernameOnlyHotkey != Keys . None )
198+ PTHotKeyManager . UnregisterHotKey ( Config . UsernameOnlyHotkeyID ) ;
182199 }
183200 #endregion
184201
@@ -657,6 +674,8 @@ private void OptionsFormShown(object sender, Tools.OptionsFormsEventArgs e)
657674 Options options = new Options ( ) ;
658675 options . AATHotkey = Config . AATHotkey ;
659676 options . PWOnlyHotkey = Config . PWOnlyHotkey ;
677+ options . UsernameOnlyHotkey = Config . UsernameOnlyHotkey ;
678+ options . UsernameOnlyEnter = Config . UsernameOnlyEnter ;
660679 options . cbPWHotkey . SelectedIndex = Config . PWEnter ? 1 : 0 ;
661680 options . cbColumnsSortable . Checked = Config . ColumnsSortable ;
662681 options . cbColumnsRememberSort . Checked = Config . ColumnsRememberSorting ;
@@ -685,6 +704,8 @@ private void OptionsForm_Closed(object sender, Tools.OptionsFormsEventArgs e)
685704 HotkeysDeactivate ( ) ;
686705 Config . AATHotkey = options . AATHotkey ;
687706 Config . PWOnlyHotkey = options . PWOnlyHotkey ;
707+ Config . UsernameOnlyHotkey = options . UsernameOnlyHotkey ;
708+ Config . UsernameOnlyEnter = options . UsernameOnlyEnter ;
688709 Config . ColumnsSortable = options . cbColumnsSortable . Checked ;
689710 Config . ColumnsRememberSorting = options . cbColumnsRememberSort . Checked ;
690711 Config . AddDBColumn = options . cbDBColumn . Checked ;
@@ -694,7 +715,7 @@ private void OptionsForm_Closed(object sender, Tools.OptionsFormsEventArgs e)
694715 Config . ExcludeExpiredGroups = options . cbExcludeExpiredGroups . Checked ;
695716 Config . SearchAsYouType = options . cbSearchAsYouType . Checked ;
696717
697- if ( ( Config . AATHotkey != Keys . None ) || ( Config . PWOnlyHotkey != Keys . None ) )
718+ if ( ( Config . AATHotkey != Keys . None ) || ( Config . PWOnlyHotkey != Keys . None ) || ( Config . UsernameOnlyHotkey != Keys . None ) )
698719 HotkeysActivate ( ) ;
699720 }
700721 #endregion
0 commit comments