/// <summary> /// Wrapper for ScreenScraper.CaptureWindow /// </summary> internal bool ReadWindow(bool checkClient = true, bool fastCapture = false) { if (BotProgram.StopFlag || checkClient && !RSClient.PrepareClient()) { return(false); } Value = null; try { LastScreenShot = DateTime.Now; Bitmap = ScreenScraper.CaptureWindow(fastCapture); Value = ScreenScraper.GetRGB(Bitmap); } catch { return(false); } finally { if (Bitmap != null) { Bitmap.Dispose(); } } return((Value != null) && (Height > 0) && (Width > 0)); }
/// <summary> /// Handles rotation cycles among the three bots /// </summary> protected override void ManageBot() { int timeToRun; while (!StopFlag) { if (!NextBot()) { return; } timeToRun = RandomWorkTime(); CurrentRunParams.RunUntil = DateTime.Now.AddMilliseconds(timeToRun); //Don't actually run a bot without login info if (string.IsNullOrEmpty(CurrentRunParams.Login) || string.IsNullOrEmpty(CurrentRunParams.Password)) { CurrentRunParams.ActiveBot.BotState = BotState.Running; CurrentRunParams.SetNewState(timeToRun); CurrentRunParams.BotIdle = true; SafeWait(timeToRun); CurrentRunParams.BotIdle = false; } else { CurrentBot.Start(); SafeWait(timeToRun); while (!CurrentBot.BotIsDone) { SafeWait(LOGOUT_CHECK_INTERVAL); } } if (!StopFlag) { RSClient.PrepareClient(true); //restart the client to get a random new world } } }
/// <summary> /// Respond to a failed attempt to log in /// </summary> /// <returns>true if the failed login is handled satisfactorily. false if the bot should stop</returns> private bool HandleFailedLogIn() { return(RSClient.PrepareClient(true)); }