LRESULT CALLBACK LowLevelKeyboardProc(int nCode,WPARAM wParam,LPARAM lParam)
{
if(nCode ==HC_ACTION && wParam == WM_KEYDOWN)
{
KBDLLHOOKSTRUCT *kblp=(KBDLLHOOKSTRUCT*)lParam;
CString temp;
DWORD dwvk = kblp->vkCode;
DWORD dwMsg = 1;
dwMsg += kblp->scanCode << 16;
dwMsg += kblp->flags << 24;
char str[20]={0};
GetKeyNameText( dwMsg, str, 20);
temp.Format("Key:%d_%s\r\n",kblp->vkCode,str);//vkCode就是键盘钩子的键值8,str是键盘钩子的键码名称eg:Backspace
SaveLog(temp);
HWND hwnd = FindWindow(NULL,"SendCommand");
}
return CallNextHookEx(Hook, nCode, wParam, lParam);
}
时间: 2024-10-06 21:10:44