if hi(getkeystate(vk_menu)) = 1 then showmessage('alt is pressed').
结果不是我想要的,我的用法那里出错?
在钩子的返回值Lparam中,如何判断alt+A等组合键的消息?

解决方案 »

  1.   

    另外如果用GetKeyState
    应该用下面的
    GetKeyState(VK_MENU) and $8000 
    要看的是最高位的值是否为1
      

  2.   

    naughtyboy(重归起跑线) :
    谢谢的你的解答.
    [email protected]
    GetKeyState(VK_MENU) and $8000 这个十六进制数是什么?我看例子的是_keypressmask=$80000不知又如何理解?
    我现在用日志钩子得到26个字母的值,还有就是看Tform里面的onkeypress以下函数得到alt的值判断方法:
    function KeysToShiftState(Keys: Word): TShiftState;
    begin
      Result := [];
      if Keys and MK_SHIFT <> 0 then Include(Result, ssShift);
      if Keys and MK_CONTROL <> 0 then Include(Result, ssCtrl);
      if Keys and MK_LBUTTON <> 0 then Include(Result, ssLeft);
      if Keys and MK_RBUTTON <> 0 then Include(Result, ssRight);
      if Keys and MK_MBUTTON <> 0 then Include(Result, ssMiddle);
      if GetKeyState(VK_MENU) < 0 then Include(Result, ssAlt);
    end;