private void StartEmbeddedExe(string exeName, IEnumerable <string> commandLineArguments) { var args = new List <string> { $@"-p ""{ApplicationNameTextBox.Text}""", $"-i {CommandDelayUpDown.Value}" }; args.AddRange(commandLineArguments); ProcessHelpers.StartEmbeddedExe(exeName, args.ToArray(), MinimizeCheckBox.Checked); }
private void Form1_Load(object sender, EventArgs e) { using (var cancellationTokenSource = new CancellationTokenSource()) { var token = cancellationTokenSource.Token; Task.Factory.StartNew(() => { while (true) { var ahkErrorWindow = Process.GetProcesses() .FirstOrDefault(p => p.MainWindowTitle == "AutoHotkey.dll"); ahkErrorWindow?.Close(); if (MageActiveCheckBox.Checked) { StartEmbeddedExe(Constants.MageExe, new[] { $@"-n ""{MageNameTextBox.Text}""", $"-h {MageHealCheckBox.Checked}", $"-b {MageBlindCheckBox.Checked}", $"-f {MageParalyzeCheckBox.Checked}", $"-v {MageVenomCheckBox.Checked}", $"-c {MageVexCheckBox.Checked}", $"-z {MageZapCheckBox.Checked}" }); } if (PoetActiveCheckBox.Checked) { StartEmbeddedExe(Constants.PoetExe, new[] { $@"-n ""{PoetNameTextBox.Text}""", $"-h {PoetHardenBodyCheckbox.Checked}" }); } if (RogueActiveCheckBox.Checked) { StartEmbeddedExe(Constants.RogueExe, new[] { $@"-n ""{RogueNameTextBox.Text}""", $"-m {RogueAttackCheckBox.Checked}", $"-a {RogueAmbushCheckBox.Checked}", $"-d {RogueDesperateAttackCheckBox.Checked}", $"-l {RogueLethalStrikeCheckBox.Checked}" }); } if (WarriorActiveCheckBox.Checked) { StartEmbeddedExe(Constants.WarriorExe, new[] { $@"-n ""{WarriorNameTextBox.Text}""", $"-m {WarriorAttackCheckBox.Checked}", $"-b {WarriorBerserkCheckBox.Checked}", $"-w {WarriorWhirlwindCheckBox.Checked}" }); } if (AutoFollowActiveCheckBox.Checked) { ProcessHelpers.StartEmbeddedExe(Constants.AutoFollowExe, new[] { $@"-p ""{ApplicationNameTextBox.Text}""", $@"-l ""{AutoFollowLeaderTextBox.Text}""", $"-d {AutoFollowDistanceUpDown.Value}" }, MinimizeCheckBox.Checked); } Thread.Sleep(PollingInterval); } }, token, TaskCreationOptions.LongRunning, TaskScheduler.Default); } }