100问 我的全局钩子为什么捕不到组合键????
自定义对象得到键盘消息中的对应值
public struct KBDLLHOOKSTRUCT
{
public int vkCode;
public int scanCode;
public int flags;
public int time;
public int dwExtraInfo;
}
if((wparam==WM_SYSKEYDOWN)&&(OnKeyPress!=null))
{
byte[] keyState = new byte[256];
GetKeyboardState(keyState);//在这里我怎么得到组合键的值,如Alt+a
byte[] buffur = new byte[2];
int i;
i = ToAscii(keystruct.vkCode,keystruct.scanCode,keyState,buffur,keystruct.flags);
if (i==1)
{
KeyPressEventArgs e =new KeyPressEventArgs((char)buffur[0]);
OnKeyPress(this,e);// 自定义事件
}
}