/// <summary> /// Calls Dispose: Unregisters the hotkey /// </summary> /// <param name="hotKey">The Hotkey</param> public static void UnRegister(HotKey hotKey) { hotKey.Dispose(); }
internal static void HotKeyUnRegister(HotKey h) { try { UnregisterHotKey(Default.Handle, h._id); } catch(Exception exception) { Logger.LogException(exception); } GCHandle.FromIntPtr(Default.GetObject(h._id)).Free(); Default.RemoveId(h._id); }
/// <summary> /// Registers the hotkey. You have to keep a reference to the returned object. /// </summary> /// <param name="keys">The keys that will work as the global hotkey.</param> /// <returns>The registered hotkey.</returns> public static HotKey Register(Keys keys) { HotKey hotKey = new HotKey { _keys = keys }; Wnd.HotKeyRegister(hotKey); return hotKey; }
internal static void HotKeyRegister(HotKey h) { h._id = Default.GetNewId(GCHandle.ToIntPtr(GCHandle.Alloc(h, GCHandleType.WeakTrackResurrection))); int modifiers = 0; if((h._keys & Keys.Alt) == Keys.Alt) { modifiers = modifiers | MOD_ALT; } if((h._keys & Keys.Control) == Keys.Control) { modifiers = modifiers | MOD_CONTROL; } if((h._keys & Keys.Shift) == Keys.Shift) { modifiers = modifiers | MOD_SHIFT; } Keys k = h._keys & ~Keys.Control & ~Keys.Shift & ~Keys.Alt; RegisterHotKey(Default.Handle, h._id, modifiers, (int)k); }