Jump to content
futurepasts

Is it possible to hold key on osbot?

Recommended Posts

Ok but maybe is it possible to spam without delay or with really low ? Cuz thats really slow biggrin.png

 
private void typeStringInstant(String output){

for(int i = 0; i < output.length(); i ++){

char c = output.charAt(i);
int code = KeyEvent.getExtendedKeyCodeForChar(c);
// Type the character
getBot().getKeyEventHandler().generateBotKeyEvent(400, System.currentTimeMillis(), 0, code, c);
}

// Press enter
getBot().getKeyEventHandler().generateBotKeyEvent(401, System.currentTimeMillis(), 0, 10, '\u0000', 1);
// Release enter
getBot().getKeyEventHandler().generateBotKeyEvent(402, System.currentTimeMillis(), 0, 10, '\u0000', 1);
}

http://osbot.org/forum/topic/85684-finished-my-new-script-but-how-do-i-type-faster/?p=952925

Edited by Fruity
Link to comment
Share on other sites

Hello i really need help to make script type letter without pressing enter.I tried robot class but  that affects user input so its shit Next i tried press key which did nothing :/ but maybe i'm  not doing it right?

 

 

private void typeStringInstant(String output){

for(int i = 0; i < output.length(); i ++){

char c = output.charAt(i);
int code = KeyEvent.getExtendedKeyCodeForChar(c);
// Type the character
getBot().getKeyEventHandler().generateBotKeyEvent(400, System.currentTimeMillis(), 0, code, c);
}

// Press enter
getBot().getKeyEventHandler().generateBotKeyEvent(401, System.currentTimeMillis(), 0, 10, '\u0000', 1);
// Release enter
getBot().getKeyEventHandler().generateBotKeyEvent(402, System.currentTimeMillis(), 0, 10, '\u0000', 1);
}

http://osbot.org/forum/topic/85684-finished-my-new-script-but-how-do-i-type-faster/?p=952925

 

 

 

I made that post a little while ago, this should be a bit more readable for you:

private void typeStringInstant(final String output){
    for(int i = 0; i < output.length(); i ++) {
        final char c = output.charAt(i);
        getBot().getKeyEventHandler().generateBotKeyEvent(KEY_TYPED, System.currentTimeMillis(), 0, KeyEvent.getExtendedKeyCodeForChar(c), c);
    }
    getBot().getKeyEventHandler().generateBotKeyEvent(KEY_TYPED, System.currentTimeMillis(), 0, VK_ENTER, '\n', KEY_LOCATION_STANDARD);
}
Edited by Explv
  • Like 1
Link to comment
Share on other sites

Ok thanks mate it worked :) to not create a new thread i will ask here :D now maybe there's any way to interact with object more human like ? Like spam click on 1 spot because

When interacting with object it moves mouse randombly around the object which is kinda bot like and of course it's accurate is really bad :D

Link to comment
Share on other sites

Ok thanks mate it worked smile.png to not create a new thread i will ask here biggrin.png now maybe there's any way to interact with object more human like ? Like spam click on 1 spot because

When interacting with object it moves mouse randombly around the object which is kinda bot like and of course it's accurate is really bad biggrin.png

 

You could so something like:

private void clickInSamePlace(final Entity entity){
    if(!getMouse().isOnCursor(entity)) entity.hover();
    else getMouse().click(false);
}

Or if you want to control the speed of the clicking, or the above doesn't work you could do:

private void clickInSamePlace(final Entity entity) throws InterruptedException {
    if(!getMouse().isOnCursor(entity)) {
        entity.hover();
    } else {
        final Point mousePos = getMouse().getPosition();
        getBot().getMouseEventHandler().generateBotMouseEvent(BUTTON1, System.currentTimeMillis(), 0, mousePos.x, mousePos.y, 1, false, BUTTON1, true);
        sleep(500); // amount to sleep between clicks
    }
}

Or if you want to click super fast all in the same spot you can do:

private void clickInSamePlace(final Entity entity, final int numClicks) {
    if(!getMouse().isOnCursor(entity)) {
        entity.hover();
    } else {
        final Point mousePos = getMouse().getPosition();
        getBot().getMouseEventHandler().generateBotMouseEvent(BUTTON1, System.currentTimeMillis(), 0, mousePos.x, mousePos.y, numClicks, false, BUTTON1, true);
    }
}
Edited by Explv
  • Like 2
Link to comment
Share on other sites

Once again thanks  mate! But i'm facing 1 more faking problem i can't resolve.After i re-enter my house x,y changes so i can't make sure my player is near the right object.

 

Example before enter:X-10490,Y-6800,Z-0

After re-enter 11400,9540,0

 

I's it possible to fix this ;D? since i can't even walk corretly :(

Link to comment
Share on other sites

Once again thanks mate! But i'm facing 1 more faking problem i can't resolve.After i re-enter my house x,y changes so i can't make sure my player is near the right object.

Example before enter:X-10490,Y-6800,Z-0

After re-enter 11400,9540,0

I's it possible to fix this ;D? since i can't even walk corretly :(

I'm not sure what you mean, can you show me your code?

Link to comment
Share on other sites

Area area = new Area(10519, 3735, 10512, 3728); inside house portal

And after i go outside of my house and re-enter it All cordinates changes

After:

Area area1 = new Area(11400, 5600, 11422, 5604); inside house portal

So it changes and i don't know why :?

I believe some areas in runescape are dynamic, and so using areas or fixed positions will not help you. You could either construct a relative path to wherever you are trying to walk to, or not use positions / areas at all

Link to comment
Share on other sites

So how then i could walk to my room inside my house :?

 

You could do it like this, with a relative path:

Create a path from the portal to the room e.g.

 

List<Position> path = new ArrayList<>();
path.add(new Position(x, y, z));
path.add(new Position(x, y, z));

And at at the same time that you made this path store the position of the portal e.g.

 

Position portalPos = new Position(0,0,0);

Then in your script when you enter the house do something like:

 

Position currentPortalPos = getObjects().closest("portal").getPosition();

int diffX = portalPos.getX() - currentPortalPos.getX();

int diffY = portalPos.getY() - currentPortalPos.getY();

for(int i = 0; i < path.length; i++) {
    path.set(i, new Position(path.get(i).getX() - diffX, path.get(i).getY() - diffY, path.get(i).getZ());
}

And then finally walk the path

 

getWalking().walkPath(path);

Either that, or try and walk to the room using an object e.g. 

getWalking().walk(getObjects().closest("whatever"));
Edited by Explv
  • Like 1
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.

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