private void EnterRandomSequence(CancellationToken cts) { // Generate a sequence to input VirtualKeyCode[] sequence = StaticHelpers.GetRandomSequence(_Random); // Press the buttons and wait 30ms then press start (in case the cutscene plays) Log.Debug("Random Sequence: [" + string.Join(", ", sequence.Select(x => x.ToString())) + "]"); // Wait until we have focus if (!_Process.HasFocus()) { Log.Message("Waiting for MHW to have focus."); } while (!_Process.HasFocus() && !cts.IsCancellationRequested) { } ; for (int i = 0; i < sequence.Length; i++) { StaticHelpers.PressKey(_InputSimulator, sequence[i], ConfigurationReader.RandomInputDelay); Thread.Sleep(ConfigurationReader.RandomInputDelay); } StaticHelpers.PressKey(_InputSimulator, VirtualKeyCode.SPACE, ConfigurationReader.RandomInputDelay); Thread.Sleep(ConfigurationReader.RandomInputDelay); StaticHelpers.PressKey(_InputSimulator, ConfigurationReader.KeyCutsceneSkip, ConfigurationReader.RandomInputDelay); }