!752 static int nWindows; sclass FoundWindow { Rect r; bool active; } static volatile new L foundWindows; p { new ShootLoop { void recognize { L topRight = //findImageAll(#1005903, #1005902); findImageAll(#1006414, #1006416); nWindows = l(topRight); 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(), y2); found.add(nu(FoundWindow, +r, +active)); selections.add(r); } foundWindows = found; } void printState(long time) { done_always(time, n(nWindows, "XP windows") + " found"); setConsoleIcon( nWindows == 0 ? "#1005834" : nWindows == 1 ? "#1005888" : nWindows == 2 ? "#1005889" : "#1005890"); showThumbnail(); } }.run(); }