mirror of
https://github.com/greenshot/greenshot
synced 2025-07-30 11:40:40 -07:00
FEATURE-1110: A first step in enabling a hotkey for opening the clipboard contents in the editor. This is not visible nor configurable in the UI, but needs to be configured in the greenshot.ini, by specifying ClipboardHotkey=<hotkey>
This commit is contained in:
parent
3adf9e9a51
commit
20e59ddd1c
4 changed files with 42 additions and 14 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is used by the hotkey trigger
|
||||
/// </summary>
|
||||
private void CaptureClipboard()
|
||||
{
|
||||
CaptureHelper.CaptureClipboard(DestinationHelper.GetDestination(EditorDestination.DESIGNATION));
|
||||
}
|
||||
|
||||
private void CaptureIE() {
|
||||
if (_conf.IECapture) {
|
||||
CaptureHelper.CaptureIe(true, null);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue