Skip to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Screenshot Renaming

Featured Replies

Is there a way to set the name of the screenshots taken by the Utilities method? Would be nice if I could put custom names for the screenshots

14 hours ago, someguy567 said:

Is there a way to set the name of the screenshots taken by the Utilities method? Would be nice if I could put custom names for the screenshots


Just use your own method to take a "screenshot".

The first function will save a screenshot as C:\Users\Username\OSBot\Data\YourScriptName\Screenshots\RSAccountName\yyyy.MM.dd_HH.mm.ss.png


The second function will save a screenshot as C:\Users\Username\OSBot\Data\YourScriptName\Screenshots\RSAccountName\SpecifiedImageName.png

 

import org.osbot.rs07.Bot;
import org.osbot.rs07.canvas.paint.Painter;
import org.osbot.rs07.script.Script;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.nio.file.Paths;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class ScreenshotUtil {

    private static final DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("yyyy.MM.dd_HH.mm.ss");

    public static void takeScreenshot(final Bot bot) throws IOException {
        takeScreenshot(bot, dateFormat.format(LocalDateTime.now()) + ".png");
    }

    public static void takeScreenshot(final Bot bot, final String imageName) throws IOException {
        Script currentScript = bot.getScriptExecutor().getCurrent();
        String scriptName = currentScript.getName();

        File screenshotDir = Paths.get(currentScript.getDirectoryData(), scriptName, "Screenshots", bot.getMethods().myPlayer().getName()).toFile();

        if (!screenshotDir.exists()) {
            screenshotDir.mkdirs();
        }

        BufferedImage gameBuffer = bot.getCanvas().getGameBuffer();

        if (gameBuffer == null) {
            return;
        }

        BufferedImage outImage = GraphicsEnvironment.getLocalGraphicsEnvironment()
                                                    .getDefaultScreenDevice()
                                                    .getDefaultConfiguration()
                                                    .createCompatibleImage(gameBuffer.getWidth(), gameBuffer.getHeight(), 1);

        Graphics2D graphics = outImage.createGraphics();

        graphics.drawImage(gameBuffer, 0, 0, null);

        for (final Painter painter : bot.getPainters()) {
            painter.onPaint(graphics);
        }

        graphics.dispose();

        File outputFile = Paths.get(screenshotDir.getAbsolutePath(), imageName).toFile();
        ImageIO.write(outImage, "PNG", outputFile);
    }
}


 

Edited by Explv

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.