AI Screenshot Analysis Automation: Lessons from Seven Days of Debugging

    A seven-day attempt to automate more than 300 daily chart screenshots revealed where AI helps—and where deterministic code works better. This practical account covers a seven-stage pipeline, unreliable login automation, costly visual recognition, and recurring model errors, with lessons on local image processing, externalized rules, validation, and recoverable workflows.

    1. A Day Lost to Repetitive Work

    Anyone who analyzes data trends will recognize this routine: log in to the same website every day, manually capture more than 300 trend charts, then inspect each chart, annotate its data, and calculate the results.

    By the time the screenshots and analysis are finished, half the day is gone. The work is not especially complex, but it demands constant attention. It is a classic high-repetition, low-creativity task.

    Because the workflow was fixed and the rules were clear, it seemed like a natural candidate for automation. Using an old laptop, I tried to hand the entire process to an AI agent. The goal was an unattended workflow from login through screenshot capture, recognition, and reporting.

    Getting there took seven days of intensive debugging. Here is how the pipeline was structured, what went wrong, and which changes finally made it work.

    2. Breaking the Workflow into Seven Stages

    The automation consisted of seven sequential stages:

    1. Automate login to the target website.
    2. Run precise searches using the required filters.
    3. Capture screenshots of the primary metrics.
    4. Capture screenshots of the secondary metrics.
    5. Convert the screenshots into numerical matrices.
    6. Calculate results using a predefined algorithm dictionary.
    7. Aggregate the results and generate reports.

    The central design principle was decoupling. Each stage handled one task, with structured data such as JSON connecting its inputs and outputs.

    If a stage failed, it could be rerun independently rather than forcing the entire pipeline to restart. This design proved essential throughout debugging.

    3. Three Major Failure Points

    Failure 1: Login Automation Could Not Handle Pop-Ups Reliably

    My first approach was to ask AI to write the login script. The problems varied widely.

    An incorrectly located search field produced irrelevant results. When the website displayed a CAPTCHA or an advertising overlay, the script stalled without making progress.

    I repeatedly instructed the AI to “close the pop-up”—at least 50 times—but each revision seemed to introduce another failure. Sometimes it clicked the wrong close button; sometimes it closed the entire page.

    Root cause: I treated exception handling as a one-time instruction rather than explicit, programmable logic.

    What worked: Pop-up dismissal and CAPTCHA waiting should not depend on the model improvising. They need deterministic selector strategies:

    • Check the known characteristics of possible close buttons.
    • Use explicit waits and timeouts.
    • Capture a screenshot when an operation fails, then retry.

    The lesson was to handle uncertainty in code rather than trying to resolve it through repeated prompting.

    Failure 2: Visual Recognition Was Expensive and Unreliable

    The screenshot-to-matrix stage was the core of the workflow. Initially, I made a common beginner’s mistake: assuming a general-purpose vision model API was the best solution.

    I started with a free tier. It sometimes misidentified even the colors, leaving the resulting matrices unusable.

    A mid-priced option improved recognition somewhat, but visual misinterpretations remained common. It confused “5” with “3” and red with blue.

    A higher-priced option delivered sufficient accuracy, but each image cost a fraction of a yuan to process. At roughly 300 images per day, the daily bill reached tens of yuan, making the monthly cost difficult to justify.

    The key realization: For charts with fixed colors, legends, and coordinates, a general-purpose vision API was unnecessarily broad for the task.

    I switched to local image processing that identified chart elements using their known colors. It ran offline, eliminated API charges, and produced more reliable recognition for these fixed-format charts.

    The following pseudocode illustrates the approach:

    1. # Pseudocode: local recognition based on known colors,
    2. # replacing a general-purpose vision API
    3. def extract_matrix(image):
    4. pixels = load_pixels(image) # Read pixel data
    5. legend = {"red": (255,0,0), "blue": (0,0,255)} # Predefined legend colors
    6. matrix = []
    7. for cell in grid_cells(image): # Split the image using the known grid
    8. color = dominant_color(cell, pixels)
    9. matrix.append(nearest_label(color, legend)) # Match the nearest color
    10. return matrix

    The principle is straightforward: use domain knowledge—fixed colors and a fixed layout—to make recognition deterministic and avoid API costs.

    For this task, that was more practical than paying for general-purpose visual understanding.

    Failure 3: Corrections Kept Reappearing

    The most frustrating issue was the correction loop.

    I assumed that once I explained an error to the AI, it would stop making that mistake. Instead, the same pattern repeated: the model made an error, I corrected it, it appeared to remember, and a few days later it made the same error again.

    Root cause: I relied on the model’s conversational memory to preserve stable, long-term rules.

    Context is not a reliable substitute for persistent configuration. If a confirmed rule exists only in a conversation, later runs can revert to earlier behavior.

    What worked: Every confirmed rule needed to be externalized into configuration files or validators.

    For example:

    • Store the color dictionary in a separate configuration file.
    • Persist the grid coordinates.
    • Keep the algorithm dictionary outside the conversation.
    • Require each run to load these configurations.
    • Validate results and reject out-of-range values or unexpected jumps.

    Once those rules became persistent code and configuration assets, the model operated within an explicit framework instead of relying on remembered instructions. That stopped the recurring correction cycle.

    4. Practical Lessons You Can Reuse

    • Prefer deterministic behavior. If code can reliably control a step—such as login interactions, pop-up handling, or fixed-color recognition—do not leave it to model improvisation.
    • Externalize rules. Turn confirmed corrections into configuration and validation logic rather than relying on conversational memory.
    • Decouple the workflow. Connect the seven stages through structured data so a failed stage can be rerun independently.
    • Choose recognition methods with cost in mind. Use local image processing for clearly defined visual patterns. Reserve general-purpose vision APIs for genuinely ambiguous cases.
    • Keep evidence of failures. Automatically capture screenshots and logs when a stage fails so debugging is based on evidence rather than blind retries.

    5. Conclusion

    The hardest part of automating repetitive work is not getting AI to write code. It is deciding which tasks benefit from flexible model reasoning and which require deterministic engineering.

    In this project, reliable automation came from drawing that boundary clearly, decoupling the workflow, and moving stable rules into persistent configuration and validators.

    Those changes turned a daily burden of more than 300 screenshots into an unattended pipeline—not by asking the model to do everything, but by giving it a well-defined role within a controlled workflow.