@@ -34,6 +34,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
3434 L"Capslock changes between the chosen pair of keyboard laguanges.\r\n"\
3535 L"Alt+Capslock changes the chosen pair of keyboard languages.\r\n"\
3636 L"Ctrl+Capslock fixes text you typed in the wrong laguange.\r\n"\
37+ L"* If both Ctrl keys (left and right) are pressed, only the selected text will be fixed.\r\n"\
3738 L"Shift+Capslock is the old Capslock that lets you type in CAPITAL.\r\n"\
3839 L"\r\n"\
3940 L"http://www.gooli.org/blog/recaps\r\n\r\n"\
@@ -506,11 +507,15 @@ HKL SwitchPair()
506507// Selects the entire current line and converts it to the current keyboard layout
507508void SwitchAndConvert (void * pParam )
508509{
509- UNREFERENCED_PARAMETER ( pParam ) ;
510+ BOOL bSelectAll = pParam != NULL ;
510511
511512 if (TryEnterCriticalSection (& g_csSwitchAndConvert ))
512513 {
513- SendKeyCombo (VK_CONTROL , 'A' , TRUE);
514+ if (bSelectAll )
515+ {
516+ SendKeyCombo (VK_CONTROL , 'A' , TRUE);
517+ }
518+
514519 HKL sourceLayout = GetCurrentLayout ();
515520 HKL targetLayout = SwitchLayout ();
516521 if (sourceLayout && targetLayout )
@@ -561,12 +566,15 @@ LRESULT CALLBACK LowLevelHookProc(int nCode, WPARAM wParam, LPARAM lParam)
561566 }
562567 else if (GetKeyState (VK_CONTROL ) < 0 )
563568 {
564- // Handle Ctrl+CapsLock - switch current layout and convert text in current field
569+ // Handle Ctrl+CapsLock - switch current layout and convert text in current field.
570+ // If both ctrl keys are pressed, don't select all text with Ctrl+A before converting.
571+
572+ BOOL bBothControlsAreDown = GetKeyState (VK_LCONTROL ) < 0 && GetKeyState (VK_RCONTROL ) < 0 ;
565573
566574 // We start SwitchLayoutAndConvertSelected in another thread since it simulates
567575 // keystrokes to copy and paste the text which call back into this hook.
568576 // That isn't good...
569- _beginthread (SwitchAndConvert , 0 , NULL );
577+ _beginthread (SwitchAndConvert , 0 , bBothControlsAreDown ? NULL : ( void * ) 1 );
570578 return 1 ; // prevent windows from handling the keystroke
571579 }
572580 else if (GetKeyState (VK_SHIFT ) < 0 )
0 commit comments