public bool RegisterHotKey(ModifierKeys modifier, Keys key, IHotKeyConsumer action) { currentId = currentId + 1; bool success = RegisterHotKey(hkWindow.Handle, currentId, (uint)modifier, (uint)key); if (success && action != null) { register.Add(GetKey(modifier, key), action); } return(success); }
private HotKeyRegister() { hkWindow = new HotKeyWindow(); register = new System.Collections.Hashtable(); hkWindow.KeyPressed += delegate(object sender, KeyPressedEventArgs args) { IHotKeyConsumer ihkc = (IHotKeyConsumer)register[GetKey(args.Modifier, args.Key)]; if (ihkc != null) { ihkc.HotKeyPressed(args); } //Disabling this so that only the consumer will consume the key press. //if (AnyHotKeyPressed != null) // AnyHotKeyPressed(this, args); }; }