sclass FoundWindow { Rect r; bool active; } sclass XP_FindWindows extends ShootLoop { volatile new L foundWindows; void recognize { L topRight = //findImageAll(#1005903, #1005902); findImageAll(#1006414, #1006416); selections.clear(); new L found; for (Rect right : topRight) { int y1 = right.y; L leftActive = findImageAllOnRow(#1006419, y1+1); L leftInactive = findImageAllOnRow(#1006420, y1+1); if (l(leftActive) + l(leftInactive) != 1) { print(" Confused! No or multiple left corners for " + right); continue; } bool active = nempty(leftActive); int x1 = first(concatLists(leftActive, leftInactive)).x-3; //print(" Window title found, probably"); int y2 = right.y2(); // title only L bottom = concatLists( findImageAllOnColumn(#1006421, x1), findImageAllOnColumn(#1006422, x1)); if (l(bottom) == 1) y2 = first(bottom).y2(); Rect r = pointsRect(x1, y1, right.x2()+4, y2); found.add(nu(FoundWindow, +r, +active)); selections.add(r); } foundWindows = found; } void printState(long time) { done_always(time, n(l(foundWindows), "XP windows") + " found"); } }