Exemple #1
0
 private static IntPtr HwndHook(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
 {
     switch (msg)
     {
     case WinApiConstants.WM_HOTKEY:
         switch (wParam.ToInt32())
         {
         case WinApiConstants.HOTKEY_ID:
             var lpInt     = (int)lParam;
             var modifiers = (Modifiers)(lpInt & 0xFFFF);
             var key       = (Keys)((lpInt >> 16) & 0xFFFF);
             foreach (var modifierKey in Enum.GetValues(typeof(Modifiers)))
             {
                 if (modifiers.HasFlag((Modifiers)modifierKey))
                 {
                     key = key | (Keys)(Enum.Parse(typeof(Keys), Enum.GetName(typeof(Modifiers), modifierKey)));
                 }
             }
             HotKeyPressedEvent?.Invoke(null, new KeyEventArgs(key));
             handled = true;
             break;
         }
         break;
     }
     return(IntPtr.Zero);
 }
Exemple #2
0
        private IntPtr HwndHook(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            const int wmHotkey = 0x0312;

            if (msg == wmHotkey)
            {
                HotKeyPressedEvent?.Invoke();
                handled = true;
            }
            return(IntPtr.Zero);
        }
Exemple #3
0
 /// <summary>
 /// Called when the associated hot key is pressed. Do not call this method manually. Use <see cref="HotKeyManager"/>
 /// </summary>
 public void HotKeyPressed(HotKeyPressedEventArgs args)
 {
     HotKeyPressedEvent?.Invoke(this, args);
 }