public void HotKeyKeyRecord() { if (Start) { MessageBox.Show("请先停止服务运行!", "发射!"); return; } if (string.IsNullOrEmpty(CurrGroupKey)) { MessageBox.Show("请先添加服务分组。", "发射!"); return; } if (this.BtnRecordKey.Tag == null) { HookKey = new GlobalKeyboardHook((Keys)Enum.Parse(typeof(Keys), this.MapleConfig.HotKeyKeyRecord)); HookKey.KeyDown += RecordKeyDownAction; HookKey.KeyUp += RecordKeyUpAction; RecordList = new List <RecordKeyData>(); RecordStopWatch.Start(); this.BtnRecordKey.Tag = true; this.LogTxt("开始录制键盘。"); this.LogStatus("开始录制键盘。"); this.LockAllControl(false); timer_Record.Start(); } else { this.timer_Record.Stop(); this.MapleConfig.ServiceData.Add(ServiceBuilder.BuildKeyRecord(CurrGroupKey, RecordList)); this.MapleConfig.Save(); this.MapleConfig.Reload(); this.ReloadServices(); this.BtnRecordKey.Tag = null; this.LogTxt("录制键盘已经停止。"); this.LogStatus("录制键盘已经停止。"); this.LockAllControl(true); HookKey.KeyDown -= RecordKeyDownAction; HookKey.KeyUp -= RecordKeyUpAction; HookKey = null; GC.Collect(); } }