/// <summary> /// Retrieves an autoclicker with given name /// </summary> /// <param name="acName"></param> /// <returns></returns> public AutoClicker?GetAutoclicker(string acName) { var acWorker = VacEnvironment.GetAcWorker(); var ac = acWorker?.AutoClickers.FirstOrDefault(a => a.Value.Name == acName).Value; if (ac is null) { ConsoleHelper.WriteWarning($"Couldn't find an autoclicker named '{acName}'. Use command 'list' to see all running autoclickers."); } return(ac); }
/// <summary> /// Starts all handlers ensuring that the application closes the running autoclicker before exiting. /// </summary> private static void StartClosingHandlers() { Console.CancelKeyPress += (sender, e) => { ConsoleHelper.WriteWarning("Application closing, running clean up!"); e.Cancel = true; VacEnvironment.GetAcWorker()?.Picnic(); VacEnvironment.Close(); Environment.Exit(0); }; AppDomain.CurrentDomain.ProcessExit += (sender, e) => VacEnvironment.GetAcWorker()?.Picnic(); }