Libraryless. Click here for Pure Java version (4772L/27K).
ifdef scrot
// Use program "scrot" to make full-screen screenshots (on Linux); prevents the bug https://bugs.openjdk.java.net/browse/JDK-7168628
// (Bug might be fixed now, so disabling.)
static bool shootScreen_useScrot = false;
endifdef
static BufferedImage shootScreen2() {
ret shootScreen2(screenRectangle());
}
static BufferedImage shootScreen2(Rectangle area) ctex {
ping();
ifdef scrot
if (shootScreen_useScrot && eq(area, screenRectangle())) {
if (!isOnPATH("scrot")) shootScreen2_fallback();
if (shootScreen_useScrot) {
S filename = "screenshot-" + randomID(12) + ".png";
File f = linux_fileInRamDisk(filename);
if (f == null) f = prepareProgramFile(filename);
try {
S cmd = "scrot " + bashQuote(f);
S out = backtick(cmd);
if (f.exists())
ret loadPNG(f);
shootScreen2_fallback();
} catch e {
print(e);
shootScreen2_fallback();
} finally {
f.delete();
}
}
}
endifdef
return new Robot().createScreenCapture(area);
}
static BufferedImage shootScreen2(Rect area) {
ret shootScreen2(area.getRectangle());
}
static BufferedImage shootScreen2(int x, int y, int w, int h) {
ret shootScreen2(new Rectangle(x, y, w, h));
}
// internal
ifdef scrot
static void shootScreen2_fallback() {
if (shootScreen_useScrot) {
if (isLinux()) print("Scrot failed. Reverting to internal screenshots.");
shootScreen_useScrot = false;
}
}
endifdefBegan life as a copy of #1001347
download show line numbers debug dex old transpilations
Travelled to 18 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mowyntqkapby, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, wnsclhtenguj
No comments. add comment