문제

when i run RegisterHotKey, it returns false. what are possible reasons?

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");
    }
}

OLD VERSION (don't judge please)

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");
}
도움이 되었습니까?

해결책

Seems that your code will always throw exception, try change to below..

    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");
             }
        }
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top