Jump to content

Where to find key types?


Recommended Posts

Posted (edited)

A simpler method would be to use:

  • keyboard.typeString("2"); for 2
  • keyboard.typeString(" "); for space

Another example:

    public void example() throws InterruptedException    {
       
            if (//something) {
                        keyboard.typeString("2");
                new ConditionalSleep(200, 200) {
                    @Override
                    public boolean condition() {
                        return //somethingelse;
                    }
                }.sleep();
            }
        }

or if you want to use widgets:

    public void example2() throws InterruptedException    {
        
        RS2Widget test= getWidgets().get(458, 1);
        
            if (test!= null && test.isVisible()) {
                        keyboard.typeString("2");
                new ConditionalSleep(200, 200) {
                    @Override
                    public boolean condition() {
                        return (//something);
                    }
                }.sleep();
            }
        }

 

Edited by Lol_marcus
Posted

I would use 

getKeyboard().typeKey(KeyEvent.VK_SPACE);  and  getKeyboard().typeKey(KeyEvent.VK_2);

or 
getKeyboard().typeKey(' ');   and getKeyboard().typeKey('2');

I don't see why you would hardcode it with a value that is not 100% obvious (to you in a few weeks of not working on it and others tring to read your code).

 

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