当我运行RegisterHotKey
时,它返回false。 可能的原因是什么?
internal void RegisterHotKey2(ModifierKeys modifier, Keys key)
{
_cID += 1;
if (!RegisterHotKey(_window.Handle, _cID, (uint)modifier, (uint)key))
{
Console.WriteLine("oh no: " + modifier.ToString() + " + " + key.ToString());
throw new InvalidOperationException("couldn't register noooooo");
}
}
旧版本(请不要评判)
internal void RegisterHotKey2(ModifierKeys modifier, Keys key)
{
_cID += 1;
if (!RegisterHotKey(_window.Handle, _cID, (uint)modifier, (uint)key))
Console.WriteLine("oh no: " + modifier.ToString() + " + " + key.ToString());
throw new InvalidOperationException("couldn't register noooooo");
}
似乎您的代码将始终抛出异常,请尝试更改为以下内容。
internal void RegisterHotKey2(ModifierKeys modifier, Keys key)
{
_cID += 1;
if (!RegisterHotKey(_window.Handle, _cID, (uint)modifier, (uint)key))
{
Console.WriteLine("oh no: " + modifier.ToString() + " + " + key.ToString());
throw new InvalidOperationException("couldn't register noooooo");
}
}