[BUG] displays the error message "Couldn't register the hotkey" at launch (#102)

* When setting 'Page down' as hotkey, the app crashes.
This commit is contained in:
Markus Hofknecht 2020-06-25 21:03:01 +02:00
parent d819e80f9f
commit bff0f3563b
2 changed files with 12 additions and 3 deletions

View file

@ -35,5 +35,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.11.1.7")]
[assembly: AssemblyFileVersion("0.11.1.7")]
[assembly: AssemblyVersion("0.11.1.8")]
[assembly: AssemblyFileVersion("0.11.1.8")]

View file

@ -450,7 +450,16 @@ namespace SystemTrayMenu.UserInterface.Controls
{
hotkey = hotkey.Remove(0, hotkey.LastIndexOf('+') + 1).Trim();
}
key = (Keys)Enum.Parse(typeof(Keys), hotkey);
try
{
hotkey = hotkey.Replace("PgDn", "PageDown").
Replace("PgUp", "PageUp");
key = (Keys)Enum.Parse(typeof(Keys), hotkey);
}
catch (ArgumentException ex)
{
Log.Warn($"{hotkey} can not be parsed", ex);
}
}
return key;
}