예제 #1
0
 public static UIntPtr KeyboardHook(int nCode, UIntPtr wParam, IntPtr lParam)
 {
     try
     {
         if (nCode == 0)
         {
             var wm = (WinAPI.WM)wParam.ToUInt32();
             Mubox.WinAPI.WindowHook.KBDLLHOOKSTRUCT keyboardHookStruct = (Mubox.WinAPI.WindowHook.KBDLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(Mubox.WinAPI.WindowHook.KBDLLHOOKSTRUCT));
             if (OnKeyboardInputReceived(wm, keyboardHookStruct))
             {
                 return(new UIntPtr(1));
             }
         }
     }
     catch (Exception ex)
     {
         ex.Log();
     }
     try
     {
         return(Mubox.WinAPI.WindowHook.CallNextHookEx(hHook, nCode, wParam, lParam));
     }
     catch (Exception ex)
     {
         ex.Log();
     }
     return(new UIntPtr(1));
 }
예제 #2
0
        public static KeyboardInput CreateFrom(WinAPI.WM wParam, Mubox.WinAPI.WindowHook.KBDLLHOOKSTRUCT hookStruct)
        {
            KeyboardInput e = new KeyboardInput();

            e.VK    = hookStruct.vkCode;
            e.Scan  = hookStruct.scanCode;
            e.Flags = hookStruct.flags;
            e.Time  = hookStruct.time;
            e.WM    = wParam;
            return(e);
        }