Exemplo n.º 1
0
 private static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam)
 {
     //regular keys
     if (nCode >= 0 && wParam == (IntPtr)WM_KEYDOWN)
     {
         int vkCode = Marshal.ReadInt32(lParam);
         KeyHandler.ChangeKey(((Keys)vkCode).ToString(), true);
     }
     if (nCode >= 0 && wParam == (IntPtr)WM_KEYUP)
     {
         int vkCode = Marshal.ReadInt32(lParam);
         KeyHandler.ChangeKey(((Keys)vkCode).ToString(), false);
     }
     //alt key
     if (nCode >= 0 && wParam == (IntPtr)WM_SYSKEYDOWN)
     {
         int vkCode = Marshal.ReadInt32(lParam);
         KeyHandler.ChangeKey(((Keys)vkCode).ToString(), true);
     }
     if (nCode >= 0 && wParam == (IntPtr)WM_SYSKEYUP)
     {
         int vkCode = Marshal.ReadInt32(lParam);
         KeyHandler.ChangeKey(((Keys)vkCode).ToString(), false);
     }
     return(CallNextHookEx(IntPtr.Zero, nCode, wParam, lParam));
 }