private void TrySetupAutostart() { if (ProcessHooker.HasExited()) // Make sure we are hooked { ProcessHooker.HookProcess(); } if (ProcessHooker.HasExited()) { MessageBox.Show("The game needs to be running!", "Error"); buttonAutoStart.Enabled = Config.Instance().IsTwitchMode&& twitch?.Client != null && twitch.Client.IsConnected; buttonAutoStart.Text = "Auto-Start"; if (!Config.Instance().ContinueTimer) { SetEnabled(false); elapsedCount = 0; stopwatch.Reset(); buttonMainToggle.Enabled = true; buttonTwitchToggle.Enabled = twitch?.Client != null && twitch.Client.IsConnected; } return; } ProcessHooker.AttachExitedMethod((sender, e) => buttonAutoStart.Invoke(new Action(() => { buttonAutoStart.Enabled = Config.Instance().IsTwitchMode&& twitch?.Client != null && twitch.Client.IsConnected; buttonAutoStart.Text = "Auto-Start"; if (!Config.Instance().ContinueTimer) { SetEnabled(false); elapsedCount = 0; stopwatch.Reset(); buttonMainToggle.Enabled = true; buttonTwitchToggle.Enabled = twitch?.Client != null && twitch.Client.IsConnected; } ProcessHooker.CloseProcess(); }))); buttonAutoStart.Enabled = false; buttonAutoStart.Text = "Waiting..."; Config.Instance().Enabled = false; autoStartTimer.Start(); buttonMainToggle.Enabled = false; buttonTwitchToggle.Enabled = twitch?.Client != null && twitch.Client.IsConnected; }
private void TrySetupAutostart() { if (ProcessHooker.HasExited()) // Make sure we are hookedtr { ProcessHooker.HookProcess(); } if (ProcessHooker.HasExited()) { buttonAutoStart.Enabled = true; buttonAutoStart.Text = "Auto-Start"; if (!Config.Instance.ContinueTimer) { SetEnabled(false); elapsedCount = 0; Stopwatch.Reset(); buttonMainToggle.Enabled = true; } return; } ProcessHooker.AttachExitedMethod((sender, e) => buttonAutoStart.Invoke(new Action(() => { buttonAutoStart.Enabled = true; buttonAutoStart.Text = "Auto-Start"; if (!Config.Instance.ContinueTimer) { SetEnabled(false); elapsedCount = 0; Stopwatch.Reset(); buttonMainToggle.Enabled = true; } ProcessHooker.CloseProcess(); }))); buttonAutoStart.Enabled = false; buttonAutoStart.Text = "Waiting..."; Config.Instance.Enabled = false; AutoStartTimer.Start(); buttonMainToggle.Enabled = false; }
private void AutoStartTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { if (ProcessHooker.HasExited()) { return; } if (Config.Instance.Enabled) { return; } MemoryHelper.Read((IntPtr)0xA4ED04, out int new_introState); MemoryHelper.Read((IntPtr)0xB7CB84, out int playingTime); if (introState == 0 && new_introState == 1 && playingTime < 1000 * 60) { buttonAutoStart.Invoke(new Action(() => SetAutostart())); } introState = new_introState; }