Пример #1
0
 ///<summary>
 ///KeyboardHookedイベントを発生させる。
 ///</summary>
 ///<param name="e">イベントのデータ。</param>
 protected virtual void OnKeyboardHooked(KeyboardHookedEventArgs e)
 {
     KeyboardHookedEventHandler handler = base.Events[EventKeyboardHooked] as KeyboardHookedEventHandler;
     if (handler != null)
         handler(this, e);
 }
Пример #2
0
 private int CallNextHook(int code, KeyboardMessage message, ref KeyboardState state)
 {
     if (code >= 0) {
         KeyboardHookedEventArgs e = new KeyboardHookedEventArgs(message, ref state);
         OnKeyboardHooked(e);
         if (e.Cancel) {
             return -1;
         }
     }
     return CallNextHookEx(IntPtr.Zero, code, message, ref state);
 }
Пример #3
0
        /// <summary>
        /// Ctrl + Altで表示切替
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void KeyHook_KeyboardHooked(object sender, KeyboardHookedEventArgs e)
        {
            if ((Control.ModifierKeys & Keys.Control) == Keys.Control && (Control.ModifierKeys & Keys.Alt) == Keys.Alt)
                OnCtrlAndAltKey = true;

            if (OnCtrlAndAltKey && e.UpDown == KeyboardUpDown.Up) {
                WindowVisibility =
                    (WindowVisibility == Visibility.Visible) ? Visibility.Collapsed : Visibility.Visible;
                OnCtrlAndAltKey = false;
            }
        }