SendKeys的问题,请帮忙解决,谢谢
public static int KeyBoardHookProc(int nCode, int wParam, IntPtr lParam)
{
if (nCode >= 0)
{
KeyBoardHookStruct kbh = (KeyBoardHookStruct)Marshal.PtrToStructure(lParam, typeof(KeyBoardHookStruct));
if (kbh.vkCode == (int)Keys.X)
{
SendKeys.Send("1001");
return 1;
}
}
return CallNextHookEx(hHook, nCode, wParam, lParam);
}
当我按键盘X的时候,SendKeys.Send("1001")被执行两次,我估计是键盘DOWN和UP,所以才显示两次,请问应该如何解决,请帮忙,谢谢。我只需要按X键后,只执行一次SendKeys.Send("1001"),请问如何解决?
------解决方案--------------------if(wparam==wm_keydown)
return;
------解决方案--------------------没错,你需要区分是按下还是抬起,可以用api函数判断
if GetKeyState(wParam) < 0 then