I am developing an windows forms application where I need to capture the key strokes like Windows + M , Windows + D, Insert + T, Insert + Tab key etc.., and I am unable to find an proper approach to this so can anyone suggest me an approach for this problem. It will be very helpful for me to solve this issue. Thanks in advance.
[Windows + D] :
public static int KeyboardLLProc(int nCode, IntPtr wParam, IntPtr lParam)
{
if ((nCode >= 0))
{
KBDLLHOOKSTRUCT pKBDLLHOOKSTRUCT = new KBDLLHOOKSTRUCT();
pKBDLLHOOKSTRUCT = (KBDLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, pKBDLLHOOKSTRUCT.GetType());
if (wParam == (IntPtr)WM_KEYDOWN)
{
if (pKBDLLHOOKSTRUCT.vkCode == (short)Keys.D)
{
bool bKeyDown = (GetAsyncKeyState((int)Keys.LWin) & 0x8000) == 0x8000;
if (bKeyDown)
{
MessageBox.Show("[Win] + D Pressed");
return 1;
}
}
}
}
return nCode < 0 ? CallNextHookEx(hHook, nCode, wParam, lParam) : 0;
}