Example #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)));
 }
Example #2
0
        private static IntPtr MouseHookProc(int nCode, int wParam, ref SSWindowsFunctions.MouseHookStructLL lParam)
        {
            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);
                    _currentDispatcher.BeginInvoke((Action)(() =>
                    {
                        if (_selectedWindow != IntPtr.Zero && _selectedWindow != _oldHwnd)
                        {
                            HighlightingCurrentWindow(_selectedWindow);
                            var textOFSelectedWindow = SSWindowsFunctions.GetText(_selectedWindow);
                            System.Diagnostics.Debug.WriteLine($"Selected window {textOFSelectedWindow}...");
                            _oldHwnd = _selectedWindow;
                        }
                        ProcessSelectingWindow(wParam);
                    }));
                    break;

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