mirror of
https://github.com/greenshot/greenshot
synced 2025-08-19 21:13:23 -07:00
BUG-1872: Hack for displaying the OneDrive is blocking the hotkey registration.
This commit is contained in:
parent
07f5463a38
commit
f07ed83722
14 changed files with 39 additions and 14 deletions
|
@ -25,6 +25,7 @@ using System.ComponentModel;
|
|||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
|
@ -610,6 +611,28 @@ namespace Greenshot {
|
|||
return success || ignoreFailedRegistration;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if OneDrive is blocking hotkeys
|
||||
/// </summary>
|
||||
/// <returns>true if onedrive has hotkeys turned on</returns>
|
||||
private static bool IsOneDriveBlockingHotkey()
|
||||
{
|
||||
if (!Environment.OSVersion.IsWindows10())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var localAppData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
|
||||
var oneDriveSettingsPath = Path.Combine(localAppData, @"Microsoft\OneDrive\settings\Personal");
|
||||
|
||||
var oneDriveSettingsFile = Directory.GetFiles(oneDriveSettingsPath, "*_screenshot.dat").FirstOrDefault();
|
||||
if (!File.Exists(oneDriveSettingsFile))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var screenshotSetting = File.ReadAllLines(oneDriveSettingsFile).Skip(1).Take(1).First();
|
||||
return "2".Equals(screenshotSetting);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Displays a dialog for the user to choose how to handle hotkey registration failures:
|
||||
/// retry (allowing to shut down the conflicting application before),
|
||||
|
@ -620,7 +643,9 @@ namespace Greenshot {
|
|||
/// <returns></returns>
|
||||
private static bool HandleFailedHotkeyRegistration(string failedKeys) {
|
||||
bool success = false;
|
||||
DialogResult dr = MessageBox.Show(Instance, Language.GetFormattedString(LangKey.warning_hotkeys, failedKeys), Language.GetString(LangKey.warning), MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Exclamation);
|
||||
var warningTitle = Language.GetString(LangKey.warning);
|
||||
var message = string.Format(Language.GetString(LangKey.warning_hotkeys), failedKeys, IsOneDriveBlockingHotkey() ? " (OneDrive)": "");
|
||||
DialogResult dr = MessageBox.Show(Instance, message, warningTitle, MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Exclamation);
|
||||
if (dr == DialogResult.Retry) {
|
||||
LOG.DebugFormat("Re-trying to register hotkeys");
|
||||
HotkeyControl.UnregisterHotkeys();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue