Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

39
LINES

< > BotCompany Repo | #1015519 // Move terminal around by dragging the title [OK]

JavaX source code (desktop) [tags: use-pretranspiled] - run with: x30.jar

Download Jar. Uses 4281K of libraries. Click here for Pure Java version (9164L/65K).

!7

static Pt moveDist = pt(400, 300);
static int minWidth = 300;

p-subst-autorestart {
  mouseMover().endAfterInterference = false;
  while licensed {
    if (mouseMover().blocked()) {
      consoleStatus("BLOCKED");
      sleepSeconds(1);
      continue;
    } else
      consoleStatus("");
    long time = sysNow();
    BufferedImage img = shootScreen2();
    Rect r = ocr_findTerminalBackground(RGBImage(img));
    writeBesideMemoryView(elapsedMS(time) + " ms");
    if (rectWidth(r) < minWidth) continue;
    Rect title = shrinkRect(40, 4, new Rect(r.x, r.y-16, r.w, 16));
    //containsColor(clipBufferedImage(img, title), 0x454545)
    bool isTitle = containsColor(clipBufferedImage(img, new Rect(centerOfRect(title), 10, 10)), 0x454545);
    if (isTitle) {
      //print(title);
      Pt p = centerOfRect(title);
      Pt p2 = Pt(p.x+random(-moveDist.x, moveDist.x), p.y+random(-moveDist.y, moveDist.y));
      Rect usable = shrinkRect(300, 20, Rect(usableWindowArea()));
      usable.h = max(40, usable.h-300);
      print("Usable: " + usable + ", p2: " + p2);
      p2 = limitPtToRect(p2, usable);
      if (eq(p, p2)) continue;
      if (robotDragMouse(toPoint(p), 100, toPoint(p2))) {
        infoBox("Moving the terminal around 'cause I'm bored.");
        print("Dragging " + p + " to " + p2);
        sleep(3000);
      }
    }
  }
}

Author comment

Began life as a copy of #1015515

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1015519
Snippet name: Move terminal around by dragging the title [OK]
Eternal ID of this version: #1015519/28
Text MD5: aab3cb85f0f9e8dbbbc4b8a3c61a35f2
Transpilation MD5: 6f4fdc286c12874488f469538607fdc4
Author: stefan
Category: javax / imaging
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-05-15 13:55:44
Source code size: 1387 bytes / 39 lines
Pitched / IR pitched: No / No
Views / Downloads: 524 / 1277
Version history: 27 change(s)
Referenced in: [show references]