Scorpius 144 Posted March 6, 2018 Since the only snippet I found on the forums was faulty and bugged, I made a few tweaks to make it work as intended. use zScreenshot() function anywhere in your code and it will create a screenshot inside your Dreambot's folder. Look for a folder with your script's name and you should find your screenshot inside it. Note: @Dinh is demi-god (Not anymore, his solution doesn't work with fresh start) Edit: just in case that lovely color is gone Edit again: jk @Dinh is demi-god Edit: one more time for rainbow @Dinh NOTE: This will not work if you run Dreambot using your root user in linux... probably if you have DBLauncher.jar in your downloads folder on windows as well (Not entirely sure) Original screenshot code taken from: https://dreambot.org/forums/index.php/topic/10870-is-there-a-screenshot-method-in-the-api/?do=findComment&comment=102126 public void zScreenshot() { Path dreambot_folder = Paths.get(System.getProperty("scripts.path")).getParent(); String file_name = getManifest().name().replace(' ', '_'); String script_save_directory = dreambot_folder.toString() + file_name; File file = new File(script_save_directory); BufferedImage image = getClient().getCanvasImage(); try { if (!file.exists() || !file.isDirectory()) { log("Creating script folder"); file.mkdir(); } log("Saving screenshot..."); ImageIO.write(image, "png", new File(String.format("%s/%s.png", script_save_directory, System.currentTimeMillis()))); } catch (Exception e) { zLogError(e); } } public void zLogError(Throwable e) { String error_string = ""; if (e.toString() != null) { error_string += "[ERROR]: " + e.toString() + "\n"; } if (e.getStackTrace() != null) { for (StackTraceElement element : e.getStackTrace()) { error_string += "[StackTrace]: " + element.toString() + "\n"; } } log(error_string); }
Dinh 496 Posted March 6, 2018 L O LL L String dreambot_folder = System.getProperty("user.home") + System.lineSeparator() + "Dreambot"
Scorpius 144 Author Posted March 6, 2018 String dreambot_folder = System.getProperty("user.home") + System.lineSeparator() + "Dreambot" Updated
Recommended Posts
Archived
This topic is now archived and is closed to further replies.