I have a C# function that I'm trying to figure out, here is the code :
private int KbHookProc(int nCode, IntPtr wParam, IntPtr lParam)
{
if (nCode >= 0 && wParam == (IntPtr)WM_KEYDOWN)
{
var hookStruct = (KbLLHookStruct)Marshal.PtrToStructure(lParam, typeof(KbLLHookStruct));
bool ctrlDown = GetKeyState(0xA2) != 0 || GetKeyState(0xA3) != 0;
if (hookStruct.vkCode == 0x56 && hookStruct.KF_REPEAT == 0)
{
Clipboard.SetText(" ");
MessageBox.Show("Hit ?);
}
}
if (nCode >= 0 && wParam == (IntPtr)WM_KEYUP)
{
MessageBox.Show("Message : KEY UP");
}
// Pass to other keyboard handlers. Makes the Ctrl+V pass through.
return CallNextHookEx(_hookHandle, nCode, wParam, lParam);
}
so what I'm looking for here is to figure out how to fire the event when the L_CTRL + V button are pressed. It is working; however I only want the event to fire after the keys are up, and for that I am lost. Can anyone offer any direction?
If you only want to respond when the keys are released, then only respond to the
WM_KEYUP
message.Remove the portion of your
if
statement that handles theWM_KEYDOWN
message.