Hello Ash,
Thank you for your question and for reaching out with your question today.
Please see the code example below that uses a system-wide hook without the need for DLL interaction:
LRESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
{
if (nCode < 0)
return CallNextHookEx(NULL, nCode, wParam, lParam);
tagKBDLLHOOKSTRUCT *str = (tagKBDLLHOOKSTRUCT *)lParam;
switch(str->flags)
{
case (LLKHF_ALTDOWN):
qDebug() << "ALT";
delete str;
return 1;
}
if (wParam == WM_KEYDOWN)
{
switch (str->vkCode)
{
case VK_RWIN:
case VK_LWIN:
case VK_LCONTROL:
case VK_RCONTROL:
case VK_APPS:
case VK_SLEEP:
case VK_MENU:
qDebug() << "SPECIAL PRESS";
delete str;
return 1;
}
}
return CallNextHookEx(NULL, nCode, wParam, lParam);
}
It blocks inputs of Ctrl, Windows Key and Alt.
If the reply was helpful, please don’t forget to upvote or accept as answer.