Skip to content

Commit dbca068

Browse files
Added an ALT button issue workarund
1 parent 7067b18 commit dbca068

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

recaps.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,23 @@ LRESULT CALLBACK LowLevelHookProc(int nCode, WPARAM wParam, LPARAM lParam)
540540
{
541541
// Handle Alt+CapsLock - switch current layout pair
542542
SwitchPair();
543+
544+
// This call of keybd_event is a workaround for the following issue:
545+
// Because we disable the WM_KEYDOWN-VK_CAPITAL message, the target
546+
// window might get the following sequence:
547+
// 1. WM_KEYDOWN-VK_MENU
548+
// 2. WM_KEYUP -VK_MENU
549+
// 3. WM_KEYUP -VK_CAPITAL
550+
// Between 1 and 2 there's the deleted message of WM_KEYDOWN-VK_CAPITAL.
551+
// Because of this sequence, the target window activates the menu, as
552+
// if the ALT button was pressed.
553+
// As a workaround, we send an additional WM_KEYUP-VK_CAPITAL message,
554+
// so it becomes:
555+
// 1. WM_KEYDOWN-VK_MENU
556+
// 2. WM_KEYUP -VK_CAPITAL
557+
// 3. WM_KEYUP -VK_MENU
558+
// 4. WM_KEYUP -VK_CAPITAL
559+
keybd_event(VK_CAPITAL, 0, KEYEVENTF_KEYUP, 0);
543560
return 1;
544561
}
545562
else if(GetKeyState(VK_CONTROL) < 0)

0 commit comments

Comments
 (0)