void Form1_FormClosing(object sender, FormClosingEventArgs e) { try { ScanThread.Abort(); BotThread.Abort(); } catch { } }
public void Start(GameInstance instance, int player) { Stopping = true; BotThread?.Join(); Instance = instance; PlayerNumber = player; Running = true; Stopping = false; BotThread = new Thread(() => Run()); BotThread.IsBackground = true; BotThread.Start(); }
private void InitializeWebDriver() { ChromeDriverService driverBuilder = null; ChromeOptions options = null; try { driverBuilder = ChromeDriverService.CreateDefaultService(); driverBuilder.HideCommandPromptWindow = true; options = new ChromeOptions(); options.AddArgument("--start-maximized"); options.AddArgument("--user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36"); options.AddExcludedArguments(new List <string>() { "enable-automation" }); options.AddArguments("--disable-extensions"); options.AddArguments(@"user-data-dir=C:\Program Data\Typeracer-Bot\profile"); options.PageLoadStrategy = PageLoadStrategy.None; chrome = new ChromeDriver(driverBuilder, options); } catch (WebDriverException) { DriverCustomPath(); } catch (ArgumentException) { DriverCustomPath(); } catch { MessageBox.Show("Unknown Error occured"); Environment.Exit(1); } botThread_obj = new BotThread(chrome); }