/// <summary> /// Hook the hot key for the authenticator /// </summary> /// <param name="config">current config settings</param> private void HookHotkey(WinAuthConfig config) { // unhook any old hotkey UnhookHotkey(); // hook new hotkey if (config != null && config.AutoLogin != null) { Dictionary<Keys, WinAPI.KeyModifiers> keys = new Dictionary<Keys, WinAPI.KeyModifiers>(); keys.Add((Keys)config.AutoLogin.HotKey, config.AutoLogin.Modifiers); m_hook = new KeyboardHook(keys); m_hook.KeyDown += new KeyboardHook.KeyboardHookEventHandler(Hotkey_KeyDown); } }
private void UnhookHotkey() { // remove the hotkey hook if (m_hook != null) { m_hook.UnHook(); m_hook = null; } }