protected override void OnClosed(EventArgs e) { Console.WriteLine(string.Format("[Log] OnClosed: {0}", DateTime.Now)); //Dispose... if (hooker != null) { hooker.Dispose(); hooker = null; } if (actionTranslator != null) { actionTranslator.Dispose(); actionTranslator = null; } if (inputTranslator != null) { inputTranslator.Dispose(); inputTranslator = null; } Process[] chromeDriverProcesses = Process.GetProcessesByName("chromedriver"); foreach (var chromeDriverProcess in chromeDriverProcesses) { if (chromeDriverProcess.MainModule.FileName.StartsWith( System.AppDomain.CurrentDomain.BaseDirectory)) { chromeDriverProcess.Kill(); } } Console.WriteLine(string.Format("[Log] End: {0}", DateTime.Now)); System.Environment.Exit(0); }
private void RestartHooker() { if (this.hooker != null) { this.hooker.Dispose(); this.hooker = null; } this.actionContainer.Clear(); this.actionsModels.Clear(); StartHooker(); }
private void StartHooker() { hooker = new AIDungeonHooker(); hooker.OnAdventurePublicIdChagned += OnAdventurePublicIdChagned; hooker.OnURLChanged += Hooker_OnURLChanged; hooker.OnScenario += OnScenario; hooker.OnUpdateAdventureMemory += OnUpdateAdventureMemory; hooker.OnAdventure += OnAdventure; hooker.OnAdventureUpdated += OnAdventureUpdated; hooker.OnActionsUndone += OnActionsUndone; hooker.OnActionAdded += OnActionAdded; hooker.OnActionUpdated += OnActionUpdated; hooker.OnActionRestored += OnActionRestored; hooker.OnInputLoadingChanged += OnInputLoadingChanged; hooker.Run(); this.Topmost = true; this.model.ShowLoading = true; Task.Run(() => { while (hooker != null && !hooker.Ready) { Thread.Sleep(1); } if (hooker == null) { Console.WriteLine("[ERROR] Hooker missing at StartHooker"); System.Environment.Exit(-1); return; } this.Dispatcher.Invoke(() => { this.model.ShowLoading = false; this.Topmost = false; this.Activate(); }); }); }