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

37
LINES

< > BotCompany Repo | #1020038 // Continuously Take Scaled Down Screenshot [doesn't save, just for image analysis]

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 1113K of libraries. Click here for Pure Java version (13790L/72K).

!7

cm ContinuousScreenshots > DynImageSurface {
  bool enabled, runInBackground = true;
  int width = 64;
  double videoInterval = 1;
  
  start {
    doEvery(videoInterval, r grab);
  }
  
  visualize {
    JComponent c = super.visualize();
    enableDoubleBuffering();
    imageSurface_pixelated(imageSurface);
    
    ret northAndCenterWithMargins(
      centerAndEastWithMargin(withLabel("Resize to width (pixels):",
        jLiveValueIntTextField(dm_fieldLiveValue('width))),
        dm_fieldCheckBox('enabled)), c);
  }
  
  bool actuallyEnabled() {
    ret enabled && (runInBackground || dm_isVisible());
  }
  
  void grab enter {
    if (!actuallyEnabled()) ret;
    time "Get Screenshot" {
      setImage(scaledDownScreenshot(width));
    }
  }
  
  enhanceFrame {
    dm_doubleFieldMenuItem(f, 'videoInterval, formTitle := "Update image every n seconds", onSet := rThread dm_reload);
  }
}

Author comment

Began life as a copy of #1019894

download  show line numbers  debug dex  old transpilations   

Travelled to 8 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1020038
Snippet name: Continuously Take Scaled Down Screenshot [doesn't save, just for image analysis]
Eternal ID of this version: #1020038/5
Text MD5: 4fe7814c45c81b3870d69fb9af0edad5
Transpilation MD5: ba81ceb1982212f76ad70db2fea38224
Author: stefan
Category: javax / stefan's os
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-12-21 19:43:55
Source code size: 938 bytes / 37 lines
Pitched / IR pitched: No / No
Views / Downloads: 298 / 802
Version history: 4 change(s)
Referenced in: #1020212 - Stack Trace showing unnoticed deadlock in old version of setField()