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.

Keyboard Input Override snippet

Featured Replies

Hey everyone! I did some light researching to reveal that there wasn't a way to be able to type in game without enabling all input. So to help myself get more familiar with java I wrote this little snippet to be able to type while all input is disabled!

I am still currently working on disabling and enabling the JFrame for when the client is minimized or is not the focused window. I currently have the  GetState() working but the onLoop does not work correctly. I am still tinkering with things as I am learning.

 

I hope this is helpful to somebody!

 

EDIT: fixed an error I didn't realize I didn't fix. Also now detects when the JFrame and client is not the main focus. It will turn off the JFrame while the client is in the background.

 

InputOverride override = new InputOverride(ScriptInstance, alpha);

in your onLoop add InputOverrideInstance.onLoop();
Spoiler

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import javax.swing.JComponent;
import javax.swing.JFrame;

import org.osbot.rs07.script.Script;

@SuppressWarnings("serial")
public class InputOverride extends JFrame {
	public InputOverride(Script api, Float alpha) {
		this.api = api;
		pointToMatch = api.getBot().getCanvas().getLocationOnScreen();
		dimensionToMatch = api.getBot().getCanvas().getSize();
		this.alpha = alpha;
		init();
	}
	protected Script api;
	protected boolean hasInit = false;
	protected void init() {
		dispose();
		setLocation(pointToMatch);
		setSize(dimensionToMatch);
		setUndecorated(true);
		setBackground(new Color(1.0f, 1.0f, 1.0f, alpha));
		addKeyListener(new KeyListener() {
			@Override
			public void keyTyped(KeyEvent e) {}
			@Override
			public void keyReleased(KeyEvent e) {}
			
			@Override
			public void keyPressed(KeyEvent e) {
				api.getKeyboard().typeKey(e.getKeyChar());
			}
		});
		setAlwaysOnTop(true);
		setVisible(true);
		hasInit = true;
	}
	public enum State{
		Idle, Reposition, Resize, AdjustAlpha, OffScreen
	}
	public State GetState() {
		if(pointToMatch != null && dimensionToMatch != null && hasInit && api != null) {
			if(!api.getBot().getCanvas().isFocusOwner() && !isFocusOwner()) {
				return State.OffScreen;
			} else {
				if(isShowing()){
					if(getLocationOnScreen().distance(pointToMatch) > 5 && getLocationOnScreen().distance(pointToMatch) < -5) {
						return State.Reposition;
					}
				} else if(dimensionToMatch.getHeight() != getSize().getHeight() && dimensionToMatch.getWidth() != getSize().getWidth()) {
					return State.Resize;
				} else if(getBackground().getAlpha() / 255 <= alpha - alphaDeadZone && getBackground().getAlpha() / 255 >= alpha + alphaDeadZone) {
					return State.AdjustAlpha;
				} else {
					return State.Idle;
				}
			}
		}
		return State.Idle;
	}
	
	public Point pointToMatch;
	public Dimension dimensionToMatch;
	public Float alpha;
	public Float deadZoneX = 5.0f;
	public Float deadZoneY = 5.0f;
	public float alphaDeadZone = 0.05f;
	
	public void onLoop() {
		pointToMatch = api.getBot().getCanvas().getLocationOnScreen();
		dimensionToMatch = api.getBot().getCanvas().getSize();
		switch (GetState()) {
		case Reposition:
			setLocation(pointToMatch.x, pointToMatch.y);
			break;
		case Resize:
			setSize(dimensionToMatch.width, dimensionToMatch.height);
			break;
		case AdjustAlpha:
			setBackground(new Color(1.0f, 1.0f, 1.0f, alpha));
			break;
		case OffScreen:
			if(isVisible())
				setVisible(false);
			break;

		default:
			if(!isVisible())
				setVisible(true);
			break;
		}
	}
	
	public void OnQuit() {
		dispose();
	}
}

 

 

Edited by Pertinate

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.