Beispiel #1
0
 private static IntPtr KeyboardHookProc(int code, int wParam, ref SSWindowsFunctions.KeyboardHookStruct lParam)
 {
     if (code >= 0 && (wParam == SSWindowsFunctions.WM_KEYDOWN || wParam == SSWindowsFunctions.WM_SYSKEYDOWN))
     {
         var key = (System.Windows.Forms.Keys)Enum.Parse(typeof (System.Windows.Forms.Keys), lParam.vkCode.ToString());
         if (key == Keys.PrintScreen)
         {
             System.Diagnostics.Debug.WriteLine($"Combination: {key}");
             ((SSBaseHookSystem)GetHookSystem()).InteractionManager.GetCommand<SSKeyboardProvider>().Publish(new SSKeyboardPayload() { Value = eScreenshotType.Screen });
         }
         else if (LastKey == Keys.LControlKey && key == Keys.NumPad1)
         {
             System.Diagnostics.Debug.WriteLine($"Combination: {LastKey}+{key}");
             ((SSBaseHookSystem)GetHookSystem()).InteractionManager.GetCommand<SSKeyboardProvider>().Publish(new SSKeyboardPayload() {Value = eScreenshotType.SelectedArea});
         }
         else if (LastKey == Keys.LControlKey && key == Keys.NumPad2)
         {
             System.Diagnostics.Debug.WriteLine($"Combination: {LastKey}+{key}");
             ((SSBaseHookSystem)GetHookSystem()).InteractionManager.GetCommand<SSKeyboardProvider>().Publish(new SSKeyboardPayload() { Value = eScreenshotType.SelectedWindow });
         }
         LastKey = key;
     }
     return SSWindowsFunctions.CallNextHookEx( ((SSBaseHookSystem)GetHookSystem()).GetHookPtr() , code, (int)wParam, SSWindowsFunctions.StructToPtr(lParam));
 }
Beispiel #2
0
        private static IntPtr MouseHookProc(int nCode, int wParam, ref SSWindowsFunctions.MouseHookStructLL lParam)
        {

            if (_oldHwnd != IntPtr.Zero)
            {
                SSWindowsFunctions.RefreshWindow(_oldHwnd);
                _oldHwnd = IntPtr.Zero;
            }

            if (nCode >= 0)
            {
                switch (_screenshotType)
                {
                    case eScreenshotType.SelectedWindow:
                        var pt = new SSWindowsFunctions.POINT() {x= lParam.pt.x, y = lParam.pt.y};
                        _selectedWindow = SSWindowsFunctions.WindowFromPoint(pt);
                        if (_selectedWindow != IntPtr.Zero)
                        {
                            HighlightingCurrentWindow(_selectedWindow);
                            ProcessSelectingWindow(wParam);
                            _oldHwnd = _selectedWindow;
                        }

                        break;
                    case eScreenshotType.SelectedArea:
                        break;
                }
            }
            return SSWindowsFunctions.CallNextHookEx(GetHookSystem().GetHookPtr(), nCode, wParam, SSWindowsFunctions.StructToPtr(lParam));
        }