Jump to content

[HELP NEEDED] Interacting with dialogues & and sending keystrokes through osbot(ex. 1, 2 ,3 etc)


Recommended Posts

Posted (edited)

Hey guys, got this little idea for an "assistive" script. Basically the only thing i want it to do is to press the proper number key for a certain answer in a dialogue window when the dialogue is active. so basically I'm going self-play but with a script quick skipping a certain dialogue now and then. I'm still very fresh to osbot and java scripting, so far I've only made a shop-buyer that quick hops between worlds, very basic stuff. The info and help I'm looking for is maybe an example/snippet that shows how to send keystrokes with osbot when a certain dialogue is open.

Hopefully this is not too much to ask for, if I manage to make something cool out of it I'll just share it here and give back to the forum for helping!

something like

dialogues.selectOption

but that instead of clicks with the mouse use the corresponding hotkey for the answer.

Edited by dot_b0T
Posted

Something like this could do what you need:

final String[] DIALOGUE_OPTIONS = {
	"Dialogue option",
};

void solveDialogue() throws InterruptedException {
	if (getDialogues().inDialogue()) {
		// In dialogue, try and find a widget for our option
		RS2Widget widget = getWidgets().getWidgetContainingText(DIALOGUE_OPTIONS);
		if (widget != null && widget.isVisible()) {
			// Widget exists and is visible, solve it
			getKeyboard().typeString(""+widget.getThirdLevelId(), false);
			sleep(2000); // Some sleep to prevent spamming
		}
	}
}

Just populate DIALOGUE_OPTIONS with the choices you want to make, and call "solveDialogue()" in onLoop.

Posted
8 minutes ago, Lemons said:

Something like this could do what you need:


final String[] DIALOGUE_OPTIONS = {
	"Dialogue option",
};

void solveDialogue() throws InterruptedException {
	if (getDialogues().inDialogue()) {
		// In dialogue, try and find a widget for our option
		RS2Widget widget = getWidgets().getWidgetContainingText(DIALOGUE_OPTIONS);
		if (widget != null && widget.isVisible()) {
			// Widget exists and is visible, solve it
			getKeyboard().typeString(""+widget.getThirdLevelId(), false);
			sleep(2000); // Some sleep to prevent spamming
		}
	}
}

Just populate DIALOGUE_OPTIONS with the choices you want to make, and call "solveDialogue()" in onLoop.

 

3 minutes ago, Chris said:

Thank you so much guys for the spot on replies, exactly what i was looking for. This will keep me occupied for a while gonna play and fool around with this now for a bit.

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