Example #1
0
 /// <summary>
 /// Raises the <see cref="AppCommandReceived"/> event.
 /// </summary>
 /// <param name="e">An <see cref="AppCommandEventArgs"/> containing event data.</param>
 private void OnAppCommandReceived(AppCommandEventArgs e)
 {
     if (this.AppCommandReceived != null)
     {
         this.AppCommandReceived(this, e);
     }
 }
Example #2
0
        /// <summary>
        /// Occurs when the callback is received for an event.
        /// </summary>
        /// <param name="nCode">The hook code.</param>
        /// <param name="wParam">A parameter containing event data.</param>
        /// <param name="lParam">A parameter containing event data.</param>
        /// <returns><b>true</b> if the event was handled, otherwise <b>false</b>.</returns>
        protected override bool OnCallback(int nCode, IntPtr wParam, IntPtr lParam)
        {
            bool handled = false;

            ////Debug.WriteLine("WHShellHook::OnCallback - {0}:{1}:{2}", nCode, wParam, lParam);

            switch (nCode)
            {
            case NativeMethods.HSHELL_APPCOMMAND:
                AppCommandEnum  cmd     = (AppCommandEnum)SafeNativeMethods.GetAppCommand(lParam);
                DeviceEnum      uDevice = (DeviceEnum)SafeNativeMethods.GetDevice(lParam);
                KeyModifierEnum dwKeys  = (KeyModifierEnum)SafeNativeMethods.GetKeyState(lParam);

                AppCommandEventArgs appCommandEventArgs = new AppCommandEventArgs()
                {
                    Command = cmd, Device = uDevice, Modifier = dwKeys
                };
                this.OnAppCommandReceived(appCommandEventArgs);

                handled = appCommandEventArgs.Handled;
                break;

            case NativeMethods.HSHELL_ACCESSIBILITYSTATE:
                AccessibilityStateEventArgs accessibilityStateEventArgs = new AccessibilityStateEventArgs()
                {
                    State = (AccessibilityStateEnum)wParam
                };
                this.OnAccessibilityStateChanged(accessibilityStateEventArgs);
                break;

            case NativeMethods.HSHELL_ACTIVATESHELLWINDOW:
            case NativeMethods.HSHELL_ENDTASK:
            case NativeMethods.HSHELL_GETMINRECT:
            case NativeMethods.HSHELL_LANGUAGE:
            case NativeMethods.HSHELL_MONITORCHANGED:
            case NativeMethods.HSHELL_REDRAW:
            case NativeMethods.HSHELL_SYSMENU:
            case NativeMethods.HSHELL_TASKMAN:
            case NativeMethods.HSHELL_WINDOWACTIVATED:
            case NativeMethods.HSHELL_WINDOWCREATED:
            case NativeMethods.HSHELL_WINDOWDESTROYED:
            case NativeMethods.HSHELL_WINDOWREPLACED:
            case NativeMethods.HSHELL_WINDOWREPLACING:
                break;
            }

            return(handled);
        }