Skip to content

Commit

Permalink
MouseHook.cpp: Although I have not been able to reproduce this issue,…
Browse files Browse the repository at this point in the history
… there have been reports of the issue being that scrolling with the mouse wheel moves to the next difference even when the Alt key is not pressed, so I will try changing GetKeyState to GetAsyncState.
  • Loading branch information
sdottaka committed Dec 9, 2024
1 parent 392510e commit 97df9cd
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions Src/MouseHook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ LRESULT CALLBACK CMouseHook::MouseProc(int nCode, WPARAM wParam, LPARAM lParam)
MOUSEHOOKSTRUCTEX* pMouseStruct = (MOUSEHOOKSTRUCTEX*)lParam;
short zDelta = HIWORD(pMouseStruct->mouseData);

if (GetKeyState(VK_MENU) & 0x8000)
if (GetAsyncKeyState(VK_MENU) & 0x8000)
{
HWND hwndTarget = GetForegroundWindow();
// When hold Alt key, use nFlags to check MK_CONTROL MK_SHIFT holding got problem, Use GetKeyState() instead.
const auto bShiftDown = GetKeyState(VK_SHIFT) & 0x8000;
const auto bControlDown = GetKeyState(VK_CONTROL) & 0x8000;
// When hold Alt key, use nFlags to check MK_CONTROL MK_SHIFT holding got problem, Use GetAsyncKeyState() instead.
const auto bShiftDown = GetAsyncKeyState(VK_SHIFT) & 0x8000;
const auto bControlDown = GetAsyncKeyState(VK_CONTROL) & 0x8000;
// zDelta > 0 scrool up, < 0 scrool down
if (zDelta > 0)
{
Expand Down Expand Up @@ -107,10 +107,10 @@ LRESULT CALLBACK CMouseHook::MouseProc(int nCode, WPARAM wParam, LPARAM lParam)
MOUSEHOOKSTRUCTEX* pMouseStruct = (MOUSEHOOKSTRUCTEX*)lParam;
short zDelta = HIWORD(pMouseStruct->mouseData);

if (GetKeyState(VK_MENU) & 0x8000)
if (GetAsyncKeyState(VK_MENU) & 0x8000)
{
HWND hwndTarget = GetForegroundWindow();
const auto bControlDown = GetKeyState(VK_CONTROL) & 0x8000;
const auto bControlDown = GetAsyncKeyState(VK_CONTROL) & 0x8000;
// zDelta > 0 scrool right, < 0 scrool left
if (zDelta > 0)
{
Expand Down

0 comments on commit 97df9cd

Please sign in to comment.