Warning: session_start(): open(/var/lib/php/sessions/sess_bl8n4qs787baapcuvlgccfdcc7, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
!7
cmodule DiscordFan > DynPrintLogAndEnabled {
transient Map protos = syncCIMap();
ISegmenter segmenter;
transient new ScreenShooter shooter;
transient ReliableSingleThread rstSegment = dm_rst(module(), r segment);
transient ReliableSingleThread rstAOA = dm_rst(module(), r aoa);
transient ImageInfo info;
transient ImageInfo latestWithAOA;
transient ImageSurface isThings;
transient double minScore = 95;
transient new Thinker thinker;
switchable double waitBeforeClick = 1.0;
switchable double patience = 1.0;
sclass Segment {
Rect rect;
BWImage bw;
*() {}
*(Rect *rect) {}
}
sclass ImageInfo {
BufferedImage image;
L segments;
new AOA_CompareImagesToProtos aoa;
Map foundProtos;
}
visual jvsplit(
jCenteredSection("Things found on screen", jscroll_center(isThings = jDoubleBufferedImageSurface())),
super);
start-thread {
dm_watchFieldAndNow enabled(r { set(shooter, +enabled) });
if (empty(protos))
putAll(protos, mapValues loadBWImage(imageSnippetIDsForNames(llQuoted("Open", "Open discord"))));
print("Have " + n2(protos, "proto"));
if (segmenter == null)
setField(segmenter := segmenterFromAGIBlue("Find things on discordapp.com #1"));
print("Have segmenter: " + segmenter);
shooter.onNewImage.add(rstSegment);
shooter.start(enter := f enter);
doEvery(1.0, rEnter { thinker.think() });
}
void segment {
BufferedImage img = shooter.latestImage;
if (!enabled || img == null || segmenter == null) ret; // man weiß ja nie...
// Have picture!!
long time = sysNow();
new ImageInfo info;
info.image = img;
info.segments = map(segmenter.get(img), r -> new Segment(r));
this.info = info;
done2_always(time, "Make " + nSegments(info.segments));
rstAOA.trigger();
}
void aoa {
ImageInfo info = this.info;
if (info == null) ret; // man weiß ja nie...
long time = sysNow();
AOA_CompareImagesToProtos aoa = info.aoa;
aoa.addProtos(protos);
for (Segment s : info.segments)
s.bw = toBWImage(bufferedImageClip(info.image, s.rect));
aoa.addImages(iotaKeys_str(collect bw(info.segments)));
stepAll(aoa);
Map> bestImageForProto = aoa.bestImageForProto;
Map> foundProtos1 = filterMapByValuePredicate(bestImageForProto, v -> score(v) >= minScore/100);
//print(+foundProtos1);
Map foundProtos = ciMap();
for (S proto, Scored scoredImage : foundProtos1)
mapPut(foundProtos, proto, getStartingWith1(info.segments, parseInt(scoredImage!)));
info.foundProtos = foundProtos;
//print('foundProtos, info.foundProtos);
if (isThings != null) isThings.setImage(
mergeBWImagesHorizontally(map bwInverted(collect bw(values(info.foundProtos)))));
print(mapValues doubleScoreAsIntPercent(bestImageForProto));
latestWithAOA = info;
done2_always("AOA", time);
}
class Thinker {
WaitForStableValue wait = new(patience);
void think {
//print("think " + enabled);
if (!enabled) ret;
ImageInfo info = latestWithAOA;
if (info == null) ret; // man weiß ja nie...
//print("Keys", sfu(keys(info.foundProtos)));
Segment s = mapGet(info.foundProtos, quote("Open discord"));
Rect r = s == null ? null : s.rect;
print(+r);
if (wait.set(r) != null) {
print("Moving mouse to Discord button!!!!");
O mover = vmBus_query mouseMover();
if (mover == null) ret with print("No mover");
callWithImportExport(mover, 'moveMouse, centerOfRect(wait!));
print("MOVED");
long startTime = sysNow();
while (licensed() && sysNow() < startTime+toMS(waitBeforeClick)) {
if (isTrue_rcall hasInterference(mover))
ret with print("INTERFERENCE, EXITING");
sleepSeconds(0.05);
}
// TODO: check mouse position
print("CLICKING!");
rcall click(mover);
print("CLICKED!");
wait.clear();
}
}
}
void cleanMeUp {
dispose shooter;
}
}