Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • zScreenshot


    Scorpius

    Recommended Posts

    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 JKY1Hab.gif

    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);
    }
    
    Link to comment
    Share on other sites

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.