• Log in or sign up for an account here: https://www.sythe.org/login

(Java) Sending text + newline to Runescape

Status
Not open for further replies.

Blupig

BEEF TOILET

$5 USD Donor
Joined
Nov 23, 2006
Sythe Gold
1,609
Messages
7,145
Location
Canada
Discord Unique ID
178533992981594112
Valentine's Singing Competition Winner
Sythe Awards 2015 Winner
Sythe Awards 2016 Winner
Sythe Awards 2020 Winner
Member of the Month Winner
MushyMuncher
Gohan has AIDS
Extreme Homosex
World War 3
I'm LAAAAAAAME
Discord Verified
Off Topic Participant
I'm writing an autotalker. It works great in general purpose applications like Notepad and even Old School Runescape, but it doesn't work in modern Runescape for some weird reason.

If you select the option to add a new line at the end of your message, modern RS will move the chat window to the search window (as if it had pressed enter first before sending a message):
BdbDnvU.png


Then it'll search for the autotalker's output.

The character sequence is as simple as this: "hello\n" as an example. I've tried combinations with \r as well.

My code is simple, I'm not doing anything crazy. Just using the Robot class.
Here's my code:
Code:
package botkitfx.Classes;

import java.awt.*;
import java.awt.event.*;
import java.util.Random;

public class KeyController
{
    Robot robot;
 
    public KeyController() throws AWTException
    {
        robot = new Robot();
    }
 
    public void SendChar(char c)
    {
        int keycode = KeyEvent.getExtendedKeyCodeForChar(c);
        robot.keyPress(keycode);
    }
 
    public void SendKeys(String text, int humanDelay, int humanOffset, boolean newline)
    {
        char[] textArr = text.toCharArray();

        for(char c : textArr)
        {
            int trueDelay;
            if (humanOffset > 0 && humanDelay > 0)
                trueDelay = humanDelay + (new Random()).nextInt(humanOffset);
            else if(humanOffset == 0 && humanDelay > 0)
                trueDelay = humanDelay;
            else
                trueDelay = 0;
         
            SendChar(c);
        }
     
        if (newline == true)
        {
            SendChar('\n');
        }
    }
}

Usage:
Code:
SendKeys("hello", 0, 0, true);

Sending VK_ENTER with Robot yields the same effect.

Ideas?

EDIT:
Basic SendKeys.Send() code in C# doesn't invoke the search box, but it glitches out pretty heavily:
OQSBK3T.png

This was trying to send "Boogers\n"
 
Last edited:
  • Like
Reactions: Ex
I don't play runescape anymore so I'm not familiar with the interface. I worked with Robot a few years ago (also Java) and if I can recall correctly, adding some delay between key sends fixed a lot of the weird behavior I was getting compared with no delay. Perhaps the game is having trouble interpreting your new line because it is coming in so fast? In runescape, is typing \n supposed to start a new line?
 
Valentine's Singing Competition Winner
Sythe Awards 2015 Winner
Sythe Awards 2016 Winner
Sythe Awards 2020 Winner
Member of the Month Winner
MushyMuncher
Gohan has AIDS
Extreme Homosex
World War 3
I'm LAAAAAAAME
Discord Verified
Off Topic Participant
I don't play runescape anymore so I'm not familiar with the interface. I worked with Robot a few years ago (also Java) and if I can recall correctly, adding some delay between key sends fixed a lot of the weird behavior I was getting compared with no delay. Perhaps the game is having trouble interpreting your new line because it is coming in so fast? In runescape, is typing \n supposed to start a new line?

Robot works with literal key presses so it uses keycodes instead of chars. Translating the char \n to a keycode is the equivalent of telling Robot to type "enter", so it should work fine. I haven't tried adding a delay though, I'll report back soon.

EDIT: Added a simple Thread.sleep(50); and it works as intended now. Thx pal <3
 
Last edited:
Status
Not open for further replies.
duelarena.gg
Back
Top