!7 !include #1015939 // PC Awareness Include static JLabel lblStatus; static JLabel visualize() { ret lblStatus; } p { lblStatus = jcenteredboldlabel("Setting Up Awareness..."); db(); if (match("i am aware", sendToLocalBotOpt_original("Awareness Bot", "are you aware"))) { setText(lblStatus, "Has awareness elsewhere."); ret; } swing { awtOnConceptChanges(lblStatus, 1000, f updateStatus); installTimer(lblStatus, 30000, f updateStatus); componentPopupMenu(lblStatus, voidfunc(JPopupMenu menu) { for (final MachineInfo info : findConcepts(MachineInfo, "me", false)) { if (!validPeer(info) || eq(osName(info), "Android")) continue; // Remote PC popup items follow addMenuItem(menu, "Grab clipboard from " + info.ip, r { S s = sendToAwareness(info.ip, "get clipboard"); if (nempty(s) && neq(s, "empty or unknown")) { L l = cast safeUnstructure(s); S type = cast first(l); if (eq(type, "text")) { S text = (S) l.get(1); copyTextToClipboard(text); print("Copied text to clipboard: " + quote(shorten(text, 100))); } else if (eq(type, "png")) { copyImageToClipboard(fromPNG((byte[]) l.get(1))); print("Copied image to clipboard."); } else print("Unknown clipboard type: " + type); } }); addMenuItem(menu, "Grab screenshot from " + info.ip, r-thread { loading "Grabbing Screenshot Through Network" { S s = sendToAwareness(info.ip, "screenshot"); if (startsWith(s, "[")) { L l = cast safeUnstructure(s); S type = cast first(l); if (eq(type, "png")) { BufferedImage img = fromPNG((byte[]) l.get(1)); showImage("Screenshot from " + info.ip + " at " + ymd_hms(), img); } } } }); } }); } print("Yo Setting Up Awareness..."); makeBot("Awareness Bot."); phonePublicCommBot(); // works for PCs too findBot_timeout = 1000*60; pingThread(null); status("Awareness Set Up!"); printMyIPs(); scanSubnet_parallel(); } svoid status(S s) { setText(lblStatus, print(s)); } svoid updateStatus { new L l; for (MachineInfo info : concatLists( findConcepts(MachineInfo, "me", true), findConcepts(MachineInfo, "me", false))) { if (!validPeer(info)) continue; l.add(info.ip + ": " + /*info.computerID*/ osName(info) + (info.me ? " [me]" : "")); } S text = isEmpty(l) ? "Looking for peers" : n(l, "machine") + ": " + join(", ", l); lblStatus.setText(text); }