Jump to content

Change Title/Icon of OSBot


Recommended Posts

Posted

I needed a easy way to track which bot is running which account, so yeah.

You can change the Title and the icon with this. Have fun :DPreview_Title.gif.a707d74dfe0e46990651fd3f543d66fc.gif

Spoiler

import sun.swing.SwingAccessor;

import javax.swing.*;
import java.awt.*;
import java.awt.image.*;

public class OSBotBar {
    private static Image iconNormal;
    private static Image iconRed;
    private static Image iconGreen;
    private static JFrame frame;
    private static String title;

    public static void setTitle(String name){
        if(frame == null)
            getFrame();
        if(title == null)
            title = frame.getTitle();

        if (frame != null) {
            frame.setTitle(title + " - " + name);
        }
    }

    public static void setIcon(Icon icon){
        if(iconNormal == null || iconRed == null || iconGreen == null)
            getIcons();

        switch (icon){
            case GREEN:
                frame.setIconImage(iconGreen);
                break;
            case RED:
                frame.setIconImage(iconRed);
                break;
            default:
                frame.setIconImage(iconNormal);
        }
    }

    private static void getIcons(){
        if(frame == null)
            getFrame();

        iconNormal = frame.getIconImage();

        ImageProducer prodRed = new FilteredImageSource( iconNormal.getSource(), new ColorFilter(0xffff0000) );
        ImageProducer prodGreen = new FilteredImageSource( iconNormal.getSource(), new ColorFilter(0xff00ff00) );

        iconRed = frame.createImage(prodRed);
        iconGreen = frame.createImage(prodGreen);
    }

    private static void getFrame(){
        Window[] windows = Window.getWindows();
        for (Window window : windows) {
            if (window instanceof JFrame) {
                JFrame jFrame = (JFrame) window;
                if (jFrame != null && jFrame.getTitle().contains("OSBot ")) {
                    frame = jFrame;
                }
            }
        }
    }

    public enum Icon{
        STANDARD,
        RED,
        GREEN
    }
}

class ColorFilter extends RGBImageFilter
{
    private int filter;
    public ColorFilter(int filter)
    {
        this.filter = filter;
        canFilterIndexColorModel = true;
    }
    public int filterRGB( int x, int y, int rgb )
    {
        return (rgb & filter);
    }
}

 

  • Like 5
Posted

This is an awesome idea, nicely done. since with java 10 you can break down the Main java process to display the child process names, you could manually set it to "runelite" and maybe help avoid the "auto detection system" (if they ever coded one to check child processes, I've yet to see it in an OSRS deob).

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...