コード例 #1
0
        internal Win32HotKey(VirtualKey key, Modifiers modifiers = 0)
        {
            _id = ++currentHotKeyId;

            Win32Handler.WithWin32HandlerInstance(instance =>
            {
                int result = RegisterHotKey(instance.MainWindowHandle, _id, (uint)modifiers, (uint)key);

                if (result == 0)
                {
                    throw new InvalidOperationException("Did not manage to register specified Win32HotKey.");
                }

                _windowHandleSource = HwndSource.FromHwnd(instance.MainWindowHandle);
                _windowHandleSource.AddHook(EventCallback);
            });
        }
コード例 #2
0
        internal static void Initialise(Window mainWindow)
        {
            Instance = new Win32Handler(mainWindow);

            Initialised?.Invoke(null, EventArgs.Empty);
        }