static int autoShoot_maxW = 500, autoShoot_maxH = 200; sclass AutoShootInfo { long screenshotTime; L segments; int considered; } static AutoShootInfo autoShoot() { ret autoShoot(f shootScreenBW); } static AutoShootInfo autoShoot(O shootFunc) { new AutoShootInfo info; info.screenshotTime = now(); BWImage screen = cast callF(shootFunc); info.segments = autoSegment(screen); for (Rect r : info.segments) { if (r.w > autoShoot_maxW || r.h > autoShoot_maxH) continue; ++info.considered; BWImage image = screen.clip(r); S md5 = md5OfBWImage(image); GrabbedImage gi = uniq(GrabbedImage, +md5); if (gi.image == null) cset(gi, +image); cset(gi, lastRect := r, lastScreenshotTime := info.screenshotTime, count := gi.count+1); } ret info; }