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).

1  
!7
2  
3  
static Pt moveDist = pt(400, 300);
4  
static int minWidth = 300;
5  
6  
p-subst-autorestart {
7  
  mouseMover().endAfterInterference = false;
8  
  while licensed {
9  
    if (mouseMover().blocked()) {
10  
      consoleStatus("BLOCKED");
11  
      sleepSeconds(1);
12  
      continue;
13  
    } else
14  
      consoleStatus("");
15  
    long time = sysNow();
16  
    BufferedImage img = shootScreen2();
17  
    Rect r = ocr_findTerminalBackground(RGBImage(img));
18  
    writeBesideMemoryView(elapsedMS(time) + " ms");
19  
    if (rectWidth(r) < minWidth) continue;
20  
    Rect title = shrinkRect(40, 4, new Rect(r.x, r.y-16, r.w, 16));
21  
    //containsColor(clipBufferedImage(img, title), 0x454545)
22  
    bool isTitle = containsColor(clipBufferedImage(img, new Rect(centerOfRect(title), 10, 10)), 0x454545);
23  
    if (isTitle) {
24  
      //print(title);
25  
      Pt p = centerOfRect(title);
26  
      Pt p2 = Pt(p.x+random(-moveDist.x, moveDist.x), p.y+random(-moveDist.y, moveDist.y));
27  
      Rect usable = shrinkRect(300, 20, Rect(usableWindowArea()));
28  
      usable.h = max(40, usable.h-300);
29  
      print("Usable: " + usable + ", p2: " + p2);
30  
      p2 = limitPtToRect(p2, usable);
31  
      if (eq(p, p2)) continue;
32  
      if (robotDragMouse(toPoint(p), 100, toPoint(p2))) {
33  
        infoBox("Moving the terminal around 'cause I'm bored.");
34  
        print("Dragging " + p + " to " + p2);
35  
        sleep(3000);
36  
      }
37  
    }
38  
  }
39  
}

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: 526 / 1280
Version history: 27 change(s)
Referenced in: [show references]