Esempio n. 1
0
 internal int hookProc(int code, int wParam, ref keyboardHookStruct lParam)
 {
     if (code >= 0)
     {
         add_keyevent(new KeyEventProcessArgs()
         {
             wParam = wParam, lParam = lParam.DeepClone()
         });
     }
     return(NativeWin32.CallNextHookEx(HHook, code, wParam, ref lParam));
 }
Esempio n. 2
0
        private static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam)
        {
            if (nCode >= 0 && (wParam == (IntPtr)WM_KEYDOWN || wParam == (IntPtr)WM_SYSKEYDOWN))
            {
                Keys number = (Keys)Marshal.ReadInt32(lParam);

                string cucc = nCode.ToString() + " | " +
                              wParam.ToString() + " | " +
                              lParam.ToString() + " | " +
                              number.ToString() + " | " +
                              Control.ModifierKeys.ToString();

                if (number == Keys.PrintScreen)
                {
                    if ((wParam == (IntPtr)256 && number == Keys.PrintScreen && Keys.None == Control.ModifierKeys))
                    {
                        System.Threading.Thread fullps = new System.Threading.Thread(() => new ScreenMode.FullScreen());
                        fullps.SetApartmentState(System.Threading.ApartmentState.STA);
                        fullps.Start();
                    }
                    else if ((wParam == (IntPtr)260 && Keys.Alt == Control.ModifierKeys && number == Keys.PrintScreen))
                    {
                        IntPtr    hWnd = NativeWin32.GetForegroundWindow();
                        Rectangle rect;
                        NativeWin32.GetWindowRect(hWnd, out rect);
                        new Thread(() => new ScreenMode.ActiveWindow(rect)).Start();
                    }
                    else if ((wParam == (IntPtr)256 && Keys.Control == Control.ModifierKeys && number == Keys.PrintScreen))
                    {
                        DesignateArea secondForm = new DesignateArea();
                        secondForm.Show();
                    }
                }
            }
            return(NativeWin32.CallNextHookEx(_hookID, nCode, wParam, lParam));
        }