diff --git a/Greenshot/Forms/MainForm.cs b/Greenshot/Forms/MainForm.cs index ce6bd92af..1a38839c8 100644 --- a/Greenshot/Forms/MainForm.cs +++ b/Greenshot/Forms/MainForm.cs @@ -608,6 +608,10 @@ namespace Greenshot.Forms { if (!RegisterWrapper(failedKeys, "CaptureLastRegion", "LastregionHotkey", _instance.CaptureLastRegion, ignoreFailedRegistration)) { success = false; } + if (!RegisterWrapper(failedKeys, "CaptureClipboard", "ClipboardHotkey", _instance.CaptureClipboard, true)) + { + success = false; + } if (_conf.IECapture) { if (!RegisterWrapper(failedKeys, "CaptureIE", "IEHotkey", _instance.CaptureIE, ignoreFailedRegistration)) { success = false; @@ -688,7 +692,12 @@ namespace Greenshot.Forms { contextmenu_capturewindow.ShortcutKeyDisplayString = HotkeyControl.GetLocalizedHotkeyStringFromString(_conf.WindowHotkey); contextmenu_capturefullscreen.ShortcutKeyDisplayString = HotkeyControl.GetLocalizedHotkeyStringFromString(_conf.FullscreenHotkey); contextmenu_captureie.ShortcutKeyDisplayString = HotkeyControl.GetLocalizedHotkeyStringFromString(_conf.IEHotkey); - } + var clipboardHotkey = HotkeyControl.GetLocalizedHotkeyStringFromString(_conf.ClipboardHotkey); + if (!string.IsNullOrEmpty(clipboardHotkey) && !"None".Equals(clipboardHotkey)) + { + contextmenu_captureclipboard.ShortcutKeyDisplayString = clipboardHotkey; + } + } private void MainFormFormClosing(object sender, FormClosingEventArgs e) { @@ -728,6 +737,14 @@ namespace Greenshot.Forms { CaptureHelper.CaptureLastRegion(true); } + /// + /// This is used by the hotkey trigger + /// + private void CaptureClipboard() + { + CaptureHelper.CaptureClipboard(DestinationHelper.GetDestination(EditorDestination.DESIGNATION)); + } + private void CaptureIE() { if (_conf.IECapture) { CaptureHelper.CaptureIe(true, null); diff --git a/Greenshot/Helpers/CaptureHelper.cs b/Greenshot/Helpers/CaptureHelper.cs index 8b5d19bd7..19acda012 100644 --- a/Greenshot/Helpers/CaptureHelper.cs +++ b/Greenshot/Helpers/CaptureHelper.cs @@ -85,11 +85,23 @@ namespace Greenshot.Helpers { PsAPI.EmptyWorkingSet(); } } + public static void CaptureClipboard() + { + using CaptureHelper captureHelper = new CaptureHelper(CaptureMode.Clipboard); + captureHelper.MakeCapture(); + } + + public static void CaptureClipboard(IDestination destination) { using CaptureHelper captureHelper = new CaptureHelper(CaptureMode.Clipboard); + if (destination != null) + { + captureHelper.AddDestination(destination); + } captureHelper.MakeCapture(); } + public static void CaptureRegion(bool captureMouse) { using CaptureHelper captureHelper = new CaptureHelper(CaptureMode.Region, captureMouse); @@ -194,12 +206,8 @@ namespace Greenshot.Helpers { } public WindowDetails SelectedCaptureWindow { - get { - return _selectedCaptureWindow; - } - set { - _selectedCaptureWindow = value; - } + get => _selectedCaptureWindow; + set => _selectedCaptureWindow = value; } private void DoCaptureFeedback() { @@ -244,7 +252,7 @@ namespace Greenshot.Helpers { Log.Debug($"Capturing with mode {_captureMode} and using Cursor {_captureMouseCursor}"); _capture.CaptureDetails.CaptureMode = _captureMode; - // Get the windows details in a seperate thread, only for those captures that have a Feedback + // Get the windows details in a separate thread, only for those captures that have a Feedback // As currently the "elements" aren't used, we don't need them yet switch (_captureMode) { case CaptureMode.Region: @@ -270,7 +278,7 @@ namespace Greenshot.Helpers { CoreConfig.CaptureDelay = 0; } - // Capture Mousecursor if we are not loading from file or clipboard, only show when needed + // Capture Mouse cursor if we are not loading from file or clipboard, only show when needed if (_captureMode != CaptureMode.File && _captureMode != CaptureMode.Clipboard) { _capture = WindowCapture.CaptureCursor(_capture); diff --git a/GreenshotPlugin/Controls/HotkeyControl.cs b/GreenshotPlugin/Controls/HotkeyControl.cs index 6e6557522..cb9f4593a 100644 --- a/GreenshotPlugin/Controls/HotkeyControl.cs +++ b/GreenshotPlugin/Controls/HotkeyControl.cs @@ -463,10 +463,10 @@ namespace GreenshotPlugin.Controls { if (RegisterHotKey(_hotkeyHwnd, _hotKeyCounter, modifiers, (uint)virtualKeyCode)) { KeyHandlers.Add(_hotKeyCounter, handler); return _hotKeyCounter++; - } else { - Log.Warn($"Couldn't register hotkey modifier {modifierKeyCode} virtualKeyCode {virtualKeyCode}"); - return -1; } + + Log.Warn($"Couldn't register hotkey modifier {modifierKeyCode} virtualKeyCode {virtualKeyCode}"); + return -1; } public static void UnregisterHotkeys() { @@ -574,9 +574,9 @@ namespace GreenshotPlugin.Controls { visibleName = visibleName.Substring(0,1) + visibleName.Substring(1).ToLower(); } return visibleName; - } else { - return givenKey.ToString(); } + + return givenKey.ToString(); } } } \ No newline at end of file diff --git a/GreenshotPlugin/Core/CoreConfiguration.cs b/GreenshotPlugin/Core/CoreConfiguration.cs index 15f408480..bf2570ce9 100644 --- a/GreenshotPlugin/Core/CoreConfiguration.cs +++ b/GreenshotPlugin/Core/CoreConfiguration.cs @@ -74,6 +74,9 @@ namespace GreenshotPlugin.Core { public string LastregionHotkey { get; set; } [IniProperty("IEHotkey", Description="Hotkey for starting the IE capture", DefaultValue="Shift + Ctrl + PrintScreen")] public string IEHotkey { get; set; } + + [IniProperty("ClipboardHotkey", Description = "Hotkey for opening the clipboard contents into the editor")] + public string ClipboardHotkey { get; set; } [IniProperty("IsFirstLaunch", Description="Is this the first time launch?", DefaultValue="true")] public bool IsFirstLaunch { get; set; }