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

42
LINES

< > BotCompany Repo | #1005673 // letUserMarkScreenArea

JavaX fragment (include)

static int letUserMarkScreenArea_shootAfterClickDelay = 1000;

static void letUserMarkScreenArea(final O f) {
  letUserMarkScreenArea(shootScreen2(), f);
}

// f: voidfunc(Rectangle r, BufferedImage screenshot) - gets called with null values on abort
static void letUserMarkScreenArea(final BufferedImage screenshot, final O f) {
  final JWindow window = showAnimationInTopRightCorner("#1005611", "Please click roughly in the area you would like to select");

  trackOneClick(voidfunc(final Point p) {
    final new Flag done;
    window.dispose();
    
    thread "Shooting Screen" {
      sleep(screenshot == null ? letUserMarkScreenArea_shootAfterClickDelay : 0);
      awt {
        final BufferedImage screenshot2 = screenshot == null ? shootScreen2() : screenshot;
  
        final ImageSurface is = imageSurface(screenshot2);
        is.setZoom(4);
        JFrame frame = showCenterFrame("Please select exact area and click OK", jScrollPane(is));
        setFrameBounds(frame, centerScreenPart(0.75));
        addToWindow(frame, withInset(imageSelectionDepend(is, jbutton("OK", r {
          Rectangle r = is.selection;
          if (r != null) {
            disposeWindow(is);
            done.raise();
            callF(f, r, screenshot2);
          }
        }))));
        is.centerPoint(p);
        onFrameClose(frame, r {
          if (!done.isUp()) {
            done.raise();
            callF(f, null, null);
          }
        });
      }
    }
  });
}

Author comment

Began life as a copy of #1005662

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1005673
Snippet name: letUserMarkScreenArea
Eternal ID of this version: #1005673/1
Text MD5: 10aef7eb66452b31230d2546ec26f810
Author: stefan
Category: javax / gui / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-12-04 18:08:59
Source code size: 1511 bytes / 42 lines
Pitched / IR pitched: No / No
Views / Downloads: 557 / 546
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)