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.

A Simple Login Handler

Featured Replies

On 15/03/2018 at 9:33 PM, gangsthurh said:

hey boyz, i wrote an update to this login handler that fixes it for the march15 patch (is stopping people at the "click here to play" button)

 

  Hide contents


//https://osbot.org/forum/topic/109560-a-simple-login-handler/
//https://osbot.org/forum/topic/109560-a-simple-login-handler/
//patched version march15 2018

package bot.steven.LDirectives;

import java.awt.Color;

import org.osbot.rs07.api.ui.RS2Widget;
import org.osbot.rs07.constants.ResponseCode;
import org.osbot.rs07.event.Event;
import org.osbot.rs07.input.mouse.RectangleDestination;
import org.osbot.rs07.listener.LoginResponseCodeListener;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.utility.ConditionalSleep;

public final class LoginEvent extends Event implements LoginResponseCodeListener {

    private String username, password;

    public LoginEvent(Script script) {
    	this.script = script;
    }
    Script script;
    
    public void setUsername(final String username) {
        this.username = username;
    }

    public void setPassword(final String password) {
        this.password = password;
    }

    
    public final int execute() throws InterruptedException {
        if (getClient().isLoggedIn() && getLobbyButton() == null) {
            setFinished();
        } else if (getLobbyButton() != null) {
            clickLobbyButton();
        } else if (isOnWorldSelectorScreen()) {
            cancelWorldSelection();
        } else {
            login();
        }
        return random(100, 150);
    }

    private boolean isOnWorldSelectorScreen() {
        return getColorPicker().isColorAt(50, 50, Color.BLACK);
    }

    private void cancelWorldSelection() {
        if (getMouse().click(new RectangleDestination(getBot(), 712, 8, 42, 8))) {
            new ConditionalSleep(3000) {
         
                public boolean condition() throws InterruptedException {
                    return !isOnWorldSelectorScreen();
                }
            }.sleep();
        }
    }

    private void login() {
        switch (getClient().getLoginUIState()) {
            case 0:
                clickExistingUsersButton();
                break;
            case 1:
                clickLoginButton();
                break;
            case 2:
                enterUserDetails();
                break;
        }
    }

    private void clickExistingUsersButton() {
        getMouse().click(new RectangleDestination(getBot(), 400, 280, 120, 20));
    }

    private void clickLoginButton() {
        getMouse().click(new RectangleDestination(getBot(), 240, 310, 120, 20));
    }

    private void enterUserDetails() {
        if (!getKeyboard().typeString(username)) {
            setFailed();
            return;
        }
        if (!getKeyboard().typeString(password)) {
            setFailed();
            return;
        }
        new ConditionalSleep(10_000) {
            
            public boolean condition() throws InterruptedException {
                return getLobbyButton() != null;
            }
        }.sleep();
    }

    private void clickLobbyButton() {
        if (getLobbyButton().interact()) {
            new ConditionalSleep(10_000) {
            
                public boolean condition() throws InterruptedException {
                    return getLobbyButton() == null;
                }
            }.sleep();
        }
    }

    private RS2Widget getLobbyButton() {
    	try{
        return script.widgets.get(378,76);//(gangsthurh) changed code here
    	//return getWidgets().getWidgetContainingText("CLICK HERE TO PLAY");
    	}catch(NullPointerException n){
    		return null;
    	}
    
    }


    public final void onResponseCode(final int responseCode) throws InterruptedException {
        if(ResponseCode.isDisabledError(responseCode)) {
            log("Login failed, account is disabled");
            setFailed();
            return;
        }

        if(ResponseCode.isConnectionError(responseCode)) {
            log("Connection error, attempts exceeded");
            setFailed();
            return;
        }
    }
}

 

 

you dont need to change the getwidgets code you can just add the try/catch and it works fine
 

Spoiler

    private RS2Widget getLobbyButton() {
    	try{
    	return getWidgets().getWidgetContainingText("CLICK HERE TO PLAY");
    	}catch(NullPointerException n){
    		return null;
    	}
    }

 

 

  • 3 weeks later...

total idiot question but how can i call this login from another class?

7 minutes ago, Zor said:

total idiot question but how can i call this login from another class?

 LoginEvent loginEvent = new LoginEvent(username, password);
                getBot().addLoginListener(loginEvent);
                execute(loginEvent);

  • 3 weeks later...

I have a problem with the script, I try to execute it and when you press "Login" it sends the following error:

Error

  • 2 months later...

When I run it, it shows NullPointerException immediately.

 

Script doesn't start if account hasn't logined / I turned off client auto login?:???:

onstart not being called before user is logged :feels:

Uncaught exception!
java.lang.NullPointerException
	at org.osbot.rs07.event.ScriptExecutor$3.run(kl:211)
	at java.awt.event.InvocationEvent.dispatch(Unknown Source)
	at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
	at java.awt.EventQueue.access$500(Unknown Source)
	at java.awt.EventQueue$3.run(Unknown Source)
	at java.awt.EventQueue$3.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)

 

Edited by Pegasus

  • 3 weeks later...

How can I call the login handler again when i get returned to the login screen for some reason?

  • 3 months later...

When I try to use this handler, It works when on logging for the first time, but whenever I try to log in again after that, nothing happens. Can someone help me out pls!!! I followed all of the instructions.

  • 3 weeks later...
On 8/14/2018 at 8:01 PM, Zummy said:

How can I call the login handler again when i get returned to the login screen for some reason?

By calling the same method again

I there a way I can get the password from Explv bot manager? Or do I have to type it as string and compile the jar again?

EDIT: I noticed by right clicking on my configuration and then "Show command", I see the email and pass. I just don't know how to retreive it in my script.

Edited by JoRouss

  • 2 months later...

getBot().isLoaded() is not working

 

 

@ Override
    public final int execute() throws InterruptedException {
        if (!getBot().isLoaded()) {
            return 1000;
        } else if (getClient().isLoggedIn() && getLobbyButton() == null) {
            getBot().getScriptExecutor().resume();
            setFinished();
        } else if (!getBot().getScriptExecutor().isPaused()) {
            getBot().getScriptExecutor().pause();
        } else if (getLobbyButton() != null) {
            clickLobbyButton();
        } else if (isOnWorldSelectorScreen()) {
            cancelWorldSelection();
        } else if (!isPasswordEmpty()) {
            clickCancelLoginButton();
        } else {
            login();
        }
        return random(100, 150);
    }

 

I got this NPE :

java.lang.NullPointerException
    at org.osbot.rs07.api.Widgets.getWidgetContainingText(tl:727)
    at com.iaox.farmer.handlers.LoginEvent.getLobbyButton(LoginEvent.java:140)
    at com.iaox.farmer.handlers.LoginEvent.execute(LoginEvent.java:37)
    at org.osbot.rs07.event.EventExecutor$2.run(zj:230)
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

Edited by Pegasus

27 minutes ago, Pegasus said:

getBot().isLoaded() is not working

 

 


@ Override
    public final int execute() throws InterruptedException {
        if (!getBot().isLoaded()) {
            return 1000;
        } else if (getClient().isLoggedIn() && getLobbyButton() == null) {
            getBot().getScriptExecutor().resume();
            setFinished();
        } else if (!getBot().getScriptExecutor().isPaused()) {
            getBot().getScriptExecutor().pause();
        } else if (getLobbyButton() != null) {
            clickLobbyButton();
        } else if (isOnWorldSelectorScreen()) {
            cancelWorldSelection();
        } else if (!isPasswordEmpty()) {
            clickCancelLoginButton();
        } else {
            login();
        }
        return random(100, 150);
    }

 

I got this NPE :

java.lang.NullPointerException
    at org.osbot.rs07.api.Widgets.getWidgetContainingText(tl:727)
    at com.iaox.farmer.handlers.LoginEvent.getLobbyButton(LoginEvent.java:140)
    at com.iaox.farmer.handlers.LoginEvent.execute(LoginEvent.java:37)
    at org.osbot.rs07.event.EventExecutor$2.run(zj:230)
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

image.png.1800c28c880e7362f802586a65173b0b.png

What does your script look like? Does it just execute the login script immediately after the client begins launching?

 

1 hour ago, hreyvirtue said:

image.png.1800c28c880e7362f802586a65173b0b.png

What does your script look like? Does it just execute the login script immediately after the client begins launching?

that script won't work.

How can the client get login before login event execute ?

9 minutes ago, Pegasus said:

 

that script won't work.

 How can the client get login before login event execute ?

If the client isn't logged in, then the login event executes, that's the point of that script

Set it on loop and adds sleeps if you need to

 

16 hours ago, hreyvirtue said:

If the client isn't logged in, then the login event executes, that's the point of that script

Set it on loop and adds sleeps if you need to

 

I mean login event execute is not working.

It is because

getBot().isLoaded() is not working

it return true even the client is still downloading data from official game.

 

 

Edited by Pegasus

  • 2 months later...

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.