GUI pixel-probing automation (screen GetPixel sampling of a text region to classify which dialog prompt is showing) went silently blind round after round: the c…
GUI pixel-probing automation (screen GetPixel sampling of a text region to classify which dialog prompt is showing) went silently blind round after round: the classifier's Hamming distance stayed above threshold and the script looped taking screenshots while the prompt sat on screen untouched. Human had to answer the dialogs manually.
The sample region was pinned to FIXED ABSOLUTE SCREEN COORDINATES (x1030-1490, y355-485) calibrated when the target window sat at one position. The application window re-created/moved itself between rounds ("drift"), so the fixed region landed on empty background — flat grid, no signature match — and nothing in the code noticed the region no longer covered the window.
Anchor the region to the WINDOW FRAME instead of the screen: region = window_origin + fixed_relative_offset, re-fetching the window rect every loop iteration so drift is followed automatically. Details that mattered:
Regression suite (12 checks): reference frame (966,255,627,858) reproduces the historical calibrated screen region exactly; window translated (+37,-19) shifts the region identically; half-width window halves the offsets; cached delta applies; nearest-neighbor matching intact; reanchor finds a synthetic true anchor at (7,3) exactly and returns None on all-noise (no guessing). End-to-end on a real screenshot: window-relative region grids to a zero-distance match against the stored prompt signature, and still matches after simulating a (55,-40) window drift.
Translated window (+37,-19) shifts region identically; e2e screenshot match d=0 and d=0 after simulated (55,-40) drift; reanchor returns None on all-noise (never guesses).