Example #1
0
 public static extern IntPtr CallNextHookEx(HandleRef hook, int code, IntPtr wParam, [In] ref KBDLLHOOKSTRUCT lParam);
        private IntPtr OnKeyboardEvent(int code, IntPtr wParam, ref KBDLLHOOKSTRUCT lParam)
        {
            if ((code < 0) || (lParam.vkCode != NativeMethods.VK_SNAPSHOT))
            {
                return NativeMethods.CallNextHookEx(new HandleRef(this._KeyboardHook, this._KeyboardHook.Handle), code, wParam, ref lParam);
            }

            if (!(this._IsPrintScreenKeyDown = ((lParam.flags & NativeMethods.LLKHF_UP) == 0)))
            {
                if (this._IsSearchMode)
                {
                    this._IsSearchMode = false;
                    IntPtr Window = this._SelectedWindow;

                    if (Window != IntPtr.Zero)
                    {
                        this._SelectedWindow = IntPtr.Zero;

                        RedrawWindow(Window);
                        JobManager.AddJob(Window);
                    }
                }
                else if ((lParam.flags & NativeMethods.LLKHF_ALTDOWN) != 0)
                {
                    this.ShowSettingsForm();
                }
                else if (NativeMethods.IsKeyDown(NativeMethods.VK_SHIFT))
                {
                    JobManager.AddJob(ImageArea.ForegroundWindow);
                }
                else if (NativeMethods.IsKeyDown(NativeMethods.VK_CONTROL))
                {
                    JobManager.AddJob(ImageArea.VirtualScreen);
                }
                else
                {
                    JobManager.AddJob(ImageArea.CurrentScreen);
                }
            }

            return new IntPtr(1);
        }