Jump 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.

Featured Replies

There is a problem with my GUI. I am trying to use SWT for this. I made a separate class next to my main one called GUI, in it I have a SWT GUI which has a combo box and a start script button.

import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.graphics.Point;

public class GUI {
	
	public String treeName;
	public static String errorMessage;
	
	protected Shell shell;

	/**
	 * Launch the application.
	 * @param args
	 */
	public static void main(String[] args) {
		try {
			GUI window = new GUI();
			window.open();
		} catch (Exception e) {
			errorMessage = "Error";
		}
	}

	/**
	 * Open the window.
	 */
	public void open() {
		Display display = Display.getDefault();
		createContents();
		shell.open();
		shell.layout();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
	}

	/**
	 * Create contents of the window.
	 */
	protected void createContents() {
		shell = new Shell();
		shell.setMinimumSize(new Point(136, 40));
		shell.setSize(272, 240);
		shell.setText("SWT Application");
		shell.setLayout(null);
		
		Combo combo = new Combo(shell, SWT.READ_ONLY);
		combo.setBounds(66, 44, 128, 23);
		combo.setItems(new String[] {"Tree", "Oak", "Willow", "Maple", "Yew", "Magic"});
		combo.select(0);
		
		Button btnNewButton = new Button(shell, SWT.NONE);
		btnNewButton.setBounds(66, 108, 128, 54);
		btnNewButton.setText("Start script");
		
		btnNewButton.addListener(SWT.Selection, new Listener() {

			@Override
			public void handleEvent(Event e) {
				treeName = combo.getText();
				shell.close();
			}
			
		});

	}
}

In my main:

public void onStart() {
	GUI gui = new GUI();
}

It's not even showing up! The logger is giving me some error messages.

Uncaught exception!
java.lang.NoClassDefFoundError: org/eclipse/swt/widgets/Composite
    at Main.onStart(Main.java:26)
    at org.osbot.rs07.event.ScriptExecutor.IiIiiiiiIiIi(yl:197)
    at org.osbot.rs07.event.ScriptExecutor.start(yl:28)
    at org.osbot.Lb.run(vf:245)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.eclipse.swt.widgets.Composite
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 7 more
[INFO][Bot #1][02/05 05:34:10 PM]: Terminating script Skeleton...
[INFO][Bot #1][02/05 05:34:10 PM]: Script Skeleton has exited!
 

Is it possible to make SWT work with OSBot?

.setVisible(); @Athylus

on your onStart()

On your onStart do:

GUI.setVisible();

while (!GUI_COMPLETE) {
sleep(300);
}

GUI.setVisible(false);

On the gui button, once it's clicked, change the gui complete boolean to true, and it'll break out of the loop, then hide the gui.

Edited by Viston

SWT is some sort of fancy library? 

OSBot doesn't allow external dependencies in scripts. You can copy paste the source code of your dependency into the script though.

Though would recommend just using normal swing.

1 hour ago, Viston said:

.setVisible(); @Athylus

on your onStart()

On your onStart do:


GUI.setVisible();

while (!GUI_COMPLETE) {
sleep(300);
}

GUI.setVisible(false);

On the gui button, once it's clicked, change the gui complete boolean to true, and it'll break out of the loop, then hide the gui.

No, just no.

 

1 hour ago, nosepicker said:

SWT is some sort of fancy library? 

OSBot doesn't allow external dependencies in scripts. You can copy paste the source code of your dependency into the script though.

Though would recommend just using normal swing.

SWT is an external library/toolkit developed by IMB, it builds upon AWT.

And Swing is built on AWT.

So @OP use swing and when displaying it pass it to the EDT because its not thread safe.

import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.graphics.Point;

Your problem is that OSBot doesn't come packaged with the SWT ("org.eclipse.swt") library.

Your solutions are either:

  1. Ask a @Zach or @Alek to see if they can add the library into OSBot. This is unlikely due to it being more overhead for something that's likely to be very niche.
  2. Find the library's source code and include that into your script.
  3. Use the Swing ("javax.swing") library, because that is packaged with Java by default. You can look into JOptionPane to achieve what it is you're after, but in quite literally one line of code.

I'd chose no.3 just because it's the easiest and doesn't add any additional overhead. You can literally just do:

String[] trees = {
	"normal",
	"oak",
	"willow"
};

Object input = JOptionPane.showInputDialog(bot.getCanvas(),
	"Select a tree", "Woodcutter", JOptionPane.QUESTION_MESSAGE,
	null, trees, trees[0]);

String tree = null;

if (input != null) {
  tree = input.toString();
}

 

Edited by liverare

  • 2 weeks later...
  • Author

Thanks for the replies, I'm sure I can figure it out from here on. I guessed that SWT was not compatible as it was not even executing in any form whatsoever. I will use swing.

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

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.