private void TextBox_KeyDown(object sender, KeyEventArgs e) { //按退格键就可以清空数据啦! if (e.KeyCode == Keys.Back) { textBox.Text = ""; registerKey = Keys.None; registerModifiers = KeyModifiers.None; return; } e.SuppressKeyPress = true; //没有修饰符也算热键?你特么在逗我! if (e.Modifiers != Keys.None) { Keys key = Keys.None; KeyModifiers modifiers = HotKeyRegister.GetModifiers(e.KeyData, out key); //只按了修饰符可不行! if (key != Keys.None) { //输入有效!显示输入的热键! registerKey = key; registerModifiers = modifiers; textBox.Text = string.Format("{0}+{1}", registerModifiers, GetKeysString(registerKey)); } } }
private void UnregisterBossKey() { if (hotKeyToRegister != null) { hotKeyToRegister.Dispose(); hotKeyToRegister = null; } }
private void RegisterBossKey() { if (HotKeyRegister.IsCombineKey(Config.RegisterModifiers, Config.RegisterKey)) { UnregisterBossKey(); hotKeyToRegister = new HotKeyRegister(formMain.Handle, 100, Config.RegisterModifiers, Config.RegisterKey); hotKeyToRegister.HotKeyPressed += new EventHandler(BossKeyPressed); } }
private void Settings_Load(object sender, EventArgs e) { Config config = plugin.Config; enableBossKey.Checked = config.EnableBossKey; muteWhenBossCome.Checked = config.MuteWhenBossCome; registerKey = config.RegisterKey; registerModifiers = config.RegisterModifiers; //显示之前保存的热键! if (HotKeyRegister.IsCombineKey(registerModifiers, registerKey)) { textBox.Text = string.Format("{0}+{1}", registerModifiers, GetKeysString(registerKey)); } }