Jump to content

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


dot_b0T

Recommended Posts

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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