private DisposableList <ScreenCapture> GetSidebarCaptures() { // Chop a bit off the bottom of the image because it starts to fade out there, making it more difficult to compare var captureRect = new Rectangle(SidebarRect.Left, SidebarRect.Top, SidebarRect.Width, SidebarRect.Height - 70); sm_log.Info("Capturing section 0 of the sidebar"); var prevCapture = new ScreenCapture(captureRect); var captures = new DisposableList <ScreenCapture> { prevCapture.Clone() }; int scrollDistance = CalculateScrollDistance(); const int maxIterations = 100; int i = 0; for (; i < maxIterations; i++) { MouseUtils.RightDrag(SidebarRect.Location.Add(new Point(0, scrollDistance)), SidebarRect.Location); // Check if we've reached the bottom if (SidebarUtil.FindVisibleSidebarHeight() <= SidebarUtil.MaxHeight) { break; } // Capture the next bit of the sidebar prevCapture.Dispose(); prevCapture = new ScreenCapture(captureRect); sm_log.Info(Invariant($"Capturing section {i + 1} of the sidebar")); captures.Add(prevCapture.Clone(new Rectangle(0, prevCapture.Rect.Height - scrollDistance, prevCapture.Rect.Width, scrollDistance))); } if (i >= maxIterations) { throw new AnalysisException(Invariant($"Couldn't find the bottom of the sidebar after {i} attempts.")); } // Capture the final bit of the sidebar var finalCapture = new ScreenCapture(SidebarRect); // Work out where it overlaps the previous part, and capture the overlap int overlap = BitmapComparer.CalculateVerticalOverlap(prevCapture.Bitmap, finalCapture.Bitmap, m_overlapComparer, 0); sm_log.Info("Capturing final section of the sidebar"); captures.Add(finalCapture.Clone(new Rectangle(0, overlap, finalCapture.Rect.Width, finalCapture.Rect.Height - overlap))); prevCapture.Dispose(); return(captures); }