Uses 1319K of libraries. Click here for Pure Java version (13516L/74K).
1 | !7 |
2 | |
3 | cmodule DiscordFan > DynPrintLogAndEnabled { |
4 | transient Map<S, BWImage> protos = syncCIMap(); |
5 | ISegmenter segmenter; |
6 | transient autoDispose new ScreenShooter shooter; |
7 | transient ReliableSingleThread rstSegment = dm_rst(module(), r segment); |
8 | transient ReliableSingleThread rstAOA = dm_rst(module(), r aoa); |
9 | transient ImageInfo info, latestWithAOA; |
10 | transient ImageSurface isThings; |
11 | transient double minScore = 95; |
12 | transient new Thinker thinker; |
13 | switchable double waitBeforeClick = 1.0; |
14 | switchable double patience = 1.0; |
15 | |
16 | sclass Segment extends BWImageAndRect { *() {} *(Rect r) { super(r); } } |
17 | sclass ImageInfo extends ImageWithProtos<Segment> {} |
18 | |
19 | visual jvsplit( |
20 | jCenteredSection("Things found on screen", jscroll_center(isThings = jDoubleBufferedImageSurface())), |
21 | super); |
22 | |
23 | start-thread { |
24 | dm_watchFieldAndNow enabled(r { set(shooter, +enabled) }); |
25 | if (empty(protos)) |
26 | putAll(protos, mapValues loadBWImage(imageSnippetIDsForNames(llQuoted("Open", "Open discord")))); |
27 | print("Have " + n2(protos, "proto")); |
28 | if (segmenter == null) |
29 | setField(segmenter := segmenterFromAGIBlue("Find things on discordapp.com #1")); |
30 | print("Have segmenter: " + segmenter); |
31 | |
32 | shooter.onNewImage.add(rstSegment); |
33 | shooter.start(enter := f<AutoCloseable> enter); |
34 | doEvery(1.0, rEnter { thinker.think() }); |
35 | } |
36 | |
37 | void segment { |
38 | BufferedImage img = shooter.latestImage; |
39 | if (!enabled || img == null || segmenter == null) ret; // man weiß ja nie... |
40 | this.info = (ImageInfo) imageWithProtos_segment(segmenter, img, |
41 | iwpClass := ImageInfo.class, segmentClass := Segment.class); |
42 | rstAOA.trigger(); |
43 | } |
44 | |
45 | void aoa { |
46 | ImageInfo info = this.info; |
47 | if (info == null) ret; |
48 | imageWithProtos_doAllOnAll(info, protos, +minScore, +isThings); |
49 | latestWithAOA = info; |
50 | } |
51 | |
52 | class Thinker { |
53 | WaitForStableValue<Rect> wait = new(patience); |
54 | |
55 | void think { |
56 | if (!enabled) ret; |
57 | ImageInfo info = latestWithAOA; |
58 | if (info == null) ret; // man weiß ja nie... |
59 | //print("Keys", sfu(keys(info.foundProtos))); |
60 | Segment s = mapGet(info.foundProtos, quote("Open discord")); |
61 | Rect r = s == null ? null : s.rect; |
62 | print(+r); |
63 | dm_moveMouseAndClick(wait.setAndClear(r), "Discord button"); |
64 | } |
65 | } |
66 | } |
Began life as a copy of #1024978
download show line numbers debug dex old transpilations
Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1025026 |
Snippet name: | Discord Fan [shortened] |
Eternal ID of this version: | #1025026/15 |
Text MD5: | fae5b1992fdc57df00b1af87d31feade |
Transpilation MD5: | 6fde94a11ef3dd79094c1904b1a959af |
Author: | stefan |
Category: | javax / visual bots |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-09-01 19:25:14 |
Source code size: | 2379 bytes / 66 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 304 / 465 |
Version history: | 14 change(s) |
Referenced in: | [show references] |