LRESULT CALLBACK JournalRecordProc(int code,WPARAM wParam,LPARAM lParam)
{
if(code==HC_ACTION)
{
msg=(EVENTMSG*)lParam;
if(msg->message==WM_KEYDOWN)
{
if(msg->paramL==VK_HOME)

{
AfxMessageBox("jwt");

}
}
}
return CallNextHookEx(h,code,wParam,lParam);
}
挂了日志钩子,然后上面是回调函数,有什么不对吗?为什么按HOME还是没有反映?
但是如果曲调那句if(msg->paramL==VK_HOME)发现按键有反映,说明可以得到键盘消息
那为什么按HOME就没反映呢?

解决方案 »

  1.   

    不知道这个对你有没有用
    http://www.cppfrance.com/code.aspx?ID=25013
      

  2.   

    if(LOBYTE(msg->paramL)==VK_HOME)
    {
        AfxMessageBox("jwt");
    }
      

  3.   

    楼上果然强啊~这个办法有用,还有一个疑惑
    LRESULT CALLBACK JournalRecordProc(int code,WPARAM wParam,LPARAM lParam)
    {
    msg=(EVENTMSG*)lParam;
    if(msg->message==WM_KEYDOWN)
    {
    if(LOBYTE(msg->paramL)=='J')
    {
    AfxMessageBox("jwt");

    }
    }

    return CallNextHookEx(h,code,wParam,lParam);
    }
    运行后按下j键为什么不停的AfxMessageBox("jwt");我只按了一下,是键盘自动重复按键的消息吗?
    疑惑,怎么避免?
      

  4.   

    The paramL member of the EVENTMSG structure specifies the virtual key code of the key that was pressed. 
    The paramH member of the EVENTMSG structure specifies the scan code. 
    不用AfxMessageBox,试下其它语句呢?