Page 3 of 6 FirstFirst 12345 ... LastLast
Results 51 to 75 of 128

Thread: Java: How To Create Your Own Bot Interface

  1. #51
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    Quote Originally Posted by Shatterhand View Post
    Applet and Canvas were AWT, heavy weight, and Swing is light weight, mixing these werent that good. This line solved it:
    menu.getPopupMenu().setLightWeightPopupEnabled(fal se);

    If you ever decide to use JavaFX then you can position the menu-bar and applet like so:
    Java Code:
    void initJFX(String world, int width, int height) throws IOException {

            //...
            //...

            root.getChildrenUnmodifiable().stream().filter(n -> n.getId().equals("menuToolBarPanel")).forEach(n -> {
                int menuWidth = (int)n.getBoundsInParent().getMinX() + (int)n.getBoundsInParent().getWidth();
                int menuHeight = (int)n.getBoundsInParent().getMinY() + (int)n.getBoundsInParent().getHeight();

                ClientApplet applet = new ClientApplet(world, width, height);
                panel.setPreferredSize(new Dimension(menuWidth, menuHeight));
                frame.add(applet, BorderLayout.CENTER);

                applet.start();
                //...
                //...
            });
        }

    That would position the applet below the menu above the applet. You can't embed the RS applet in a swing-node. It just doesn't work so the above was the only solution I could come up with OTHER than messing with the properties and weights.
    Last edited by Brandon; 10-12-2014 at 12:08 PM.
    I am Ggzz..
    Hackintosher

  2. #52
    Join Date
    Jan 2012
    Posts
    1,104
    Mentioned
    18 Post(s)
    Quoted
    211 Post(s)

    Default

    Quote Originally Posted by Brandon View Post
    If you ever decide to use JavaFX then you can position the menu-bar and applet like so:
    Java Code:
    void initJFX(String world, int width, int height) throws IOException {

            //...
            //...

            root.getChildrenUnmodifiable().stream().filter(n -> n.getId().equals("menuToolBarPanel")).forEach(n -> {
                int menuWidth = (int)n.getBoundsInParent().getMinX() + (int)n.getBoundsInParent().getWidth();
                int menuHeight = (int)n.getBoundsInParent().getMinY() + (int)n.getBoundsInParent().getHeight();

                ClientApplet applet = new ClientApplet(world, width, height);
                panel.setPreferredSize(new Dimension(menuWidth, menuHeight));
                frame.add(applet, BorderLayout.CENTER);

                applet.start();
                //...
                //...
            });
        }

    That would position the applet below the menu above the applet. You can't embed the RS applet in a swing-node. It just doesn't work so the above was the only solution I could come up with OTHER than messing with the properties and weights.
    Does JavaFX solve this problem?

    The applet would move up a little each time something is changed on the JFrame.

  3. #53
    Join Date
    Mar 2012
    Location
    127.0.0.1
    Posts
    3,383
    Mentioned
    95 Post(s)
    Quoted
    717 Post(s)

    Default

    Quote Originally Posted by Shatterhand View Post
    Does JavaFX solve this problem?

    The applet would move up a little each time something is changed on the JFrame.
    For some reason, adding this to PulseBots Canvas class fixed the jumping up and down

    Java Code:
    @Override
        public void setLocation(int x, int y) {}

  4. #54
    Join Date
    Jan 2012
    Posts
    1,104
    Mentioned
    18 Post(s)
    Quoted
    211 Post(s)

    Default

    Quote Originally Posted by NKN View Post
    For some reason, adding this to PulseBots Canvas class fixed the jumping up and down

    Java Code:
    @Override
        public void setLocation(int x, int y) {}
    Oh wow that worked, tyvm!

  5. #55
    Join Date
    Jun 2008
    Posts
    15
    Mentioned
    0 Post(s)
    Quoted
    11 Post(s)

    Default

    Quote Originally Posted by Shatterhand View Post
    Oh wow that worked, tyvm!
    Another solution I found for this was to set the applet's layout to null.

  6. #56
    Join Date
    Jun 2008
    Posts
    15
    Mentioned
    0 Post(s)
    Quoted
    11 Post(s)

    Default

    Thank you @Brandon; and @NKN; for your help regarding the canvas override. Now I've run in a slight issue relating the the dimensions of the canvas; Being a tabbed OS/RS3 loader, OS is of course a fixed size, however I have allowed for RS3 to be resized with the panel in which it's contained. The layouts are set to automatically adjust to the according version, and the applet resizes as expected.

    In order for the canvas' dimensions to comply with the applets' resizing, I would be required to redefine the BufferedImage for game/paint buffer, correct?
    I'm assuming the best approach would be to create a listener for applet resizing which redefines the client's BufferedImage according the the applet's size.
    If this is, would it not cause any synchronization issues, as the Canvas' paintGraphics method could be invoked whilst the BufferedImage is being redefined.

  7. #57
    Join Date
    Mar 2012
    Location
    127.0.0.1
    Posts
    3,383
    Mentioned
    95 Post(s)
    Quoted
    717 Post(s)

    Default

    Quote Originally Posted by computerichy View Post
    Thank you @Brandon; and @NKN; for your help regarding the canvas override. Now I've run in a slight issue relating the the dimensions of the canvas; Being a tabbed OS/RS3 loader, OS is of course a fixed size, however I have allowed for RS3 to be resized with the panel in which it's contained. The layouts are set to automatically adjust to the according version, and the applet resizes as expected.

    In order for the canvas' dimensions to comply with the applets' resizing, I would be required to redefine the BufferedImage for game/paint buffer, correct?
    I'm assuming the best approach would be to create a listener for applet resizing which redefines the client's BufferedImage according the the applet's size.
    If this is, would it not cause any synchronization issues, as the Canvas' paintGraphics method could be invoked whilst the BufferedImage is being redefined.

    Can you humor me and post the code of your Canvas class and where you define the bufferedimages.

  8. #58
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    Quote Originally Posted by computerichy View Post
    In order for the canvas' dimensions to comply with the applets' resizing, I would be required to redefine the BufferedImage for game/paint buffer, correct?
    I'm assuming the best approach would be to create a listener for applet resizing which redefines the client's BufferedImage according the the applet's size.
    If this is, would it not cause any synchronization issues, as the Canvas' paintGraphics method could be invoked whilst the BufferedImage is being redefined.

    1. Yes. You'd need to create a new BufferedImage that is the size as the new canvas dimensions. Not sure how you resized the canvas to be the same size as the panel it's in.. Did you explicitly call resize? Not sure that if a layout manager would work. I think that's what you're using.. Usually I just set my JPanel to borderlayout(0, 0) and place the applet in that.. it does its own resizing and withing the paint graphics, I renewed my buffer.. Could also call applet.resize();

    2. I actually can't see it causing sync.. why would it?

    Whenever I did the canvas paintGraphics I always checked the size first:

    Java Code:
    @Override
        public Graphics getGraphics() {
            //check for null.. bleh..
            if (this.backBuffer.getWidth() != this.getWidth()......) {
                //create new back buffer..
            }

            //whatever else..
        }

    Never had an issue with resizing or swapping out the back buffer for a new one.. Sometimes, if I prefer to keep one buffer throughout the entire game (for any game), I allocate screen_width x screen_height x BGRA and only use as much as client_width * client_height * BGRA.. the rest would be black if not used. This is good for shared-memory (sometimes) as it sucks re-allocating.. But you're using tabs.. so I wouldn't over-allocate then..
    Last edited by Brandon; 10-24-2014 at 04:24 AM.
    I am Ggzz..
    Hackintosher

  9. #59
    Join Date
    Dec 2014
    Posts
    12
    Mentioned
    0 Post(s)
    Quoted
    5 Post(s)

    Default

    The main question now is:
    How to hook the OSRS client, get their hooks and make an API?

    Beside that nice tutorial!

  10. #60
    Join Date
    Mar 2012
    Location
    127.0.0.1
    Posts
    3,383
    Mentioned
    95 Post(s)
    Quoted
    717 Post(s)

    Default

    Quote Originally Posted by Zhendos View Post
    The main question now is:
    How to hook the OSRS client, get their hooks and make an API?

    Beside that nice tutorial!
    Download ASM.

    Download OSRS client.

    Use ASM to write an updater.

    Dump hooks from updater.

    Write API.

  11. #61
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    Quote Originally Posted by Zhendos View Post
    The main question now is:
    How to hook the OSRS client, get their hooks and make an API?

    Beside that nice tutorial!

    Are you asking how to make an updater? Or are you asking just how to "hook" fields that you already have from somewhere?

    https://villavu.com/forum/showthread...24#post1279724


    The idea is that once you know your fields, you do:

    Field f = loader.loadClass("ClassName").getDeclaredField("Fi eldName");

    You set the field accessible:

    f.setAccessible(true);

    and if the field is static you do: f.get*(null); but if its not, you do: f.get*(instance);


    That's the gist of it.. See here for a better idea: http://www.powerbot.org/community/to...tion-tutorial/
    Last edited by Brandon; 12-21-2014 at 04:20 PM.
    I am Ggzz..
    Hackintosher

  12. #62
    Join Date
    Dec 2014
    Posts
    12
    Mentioned
    0 Post(s)
    Quoted
    5 Post(s)

    Default

    What this tutorial is doing is loading the OSRS client via URL.
    What you said yes, I'm looking for some tutorials for making an OSRS loader and learning about bytecode for hooking the RuneScape client.
    I've seen a RuneScape loader in GitHub but I don't understand most code and need some tutorials first to know how it's buikd uo.

    I am currently doing ths tutorial with the RuneScape client without hooks and an RS loader.
    Beside that I've a lot of experiece writing scripts on multiple bots.

    Thanks for the reply and nice to see you're still active!

  13. #63
    Join Date
    Mar 2012
    Location
    127.0.0.1
    Posts
    3,383
    Mentioned
    95 Post(s)
    Quoted
    717 Post(s)

    Default

    Quote Originally Posted by Zhendos View Post
    What this tutorial is doing is loading the OSRS client via URL.
    What you said yes, I'm looking for some tutorials for making an OSRS loader and learning about bytecode for hooking the RuneScape client.
    I've seen a RuneScape loader in GitHub but I don't understand most code and need some tutorials first to know how it's buikd uo.

    I am currently doing ths tutorial with the RuneScape client without hooks and an RS loader.
    Beside that I've a lot of experiece writing scripts on multiple bots.

    Thanks for the reply and nice to see you're still active!
    You're probably going to need a lot more than just script writing knowledge before you can make an updater.

    I'd advise learning about Java in itself if you haven't already, (More so than just API's from bots.)


    Then if you're ready, learn about the JVM specification and java bytecode. Check out http://rs-hacking.com for more info AFTER you've done those two prior.

  14. #64
    Join Date
    Dec 2014
    Posts
    12
    Mentioned
    0 Post(s)
    Quoted
    5 Post(s)

    Default

    I've beside writing scripts making some usefull things in java such for mathematic the ABC formula and things like this, making a runescape bot interface, looking at the code, how it's build up, edit things and look at results.

    Thanks for your tips anyway.

  15. #65
    Join Date
    Jan 2012
    Posts
    1,104
    Mentioned
    18 Post(s)
    Quoted
    211 Post(s)

    Default

    Quote Originally Posted by Zhendos View Post
    I've beside writing scripts making some usefull things in java such for mathematic the ABC formula and things like this, making a runescape bot interface, looking at the code, how it's build up, edit things and look at results.

    Thanks for your tips anyway.
    At first I didnt understand much about reflection stuff and quit it for months but second time I got it. For these stuff you better check out the rs hacking forum as NKN said.

    This tutorial gave me the start to make my own client which I have been maintaining for half a year and now I am making my own updater aswell. There is always something new to learn. Dont give up, good luck!

  16. #66
    Join Date
    Mar 2012
    Location
    127.0.0.1
    Posts
    3,383
    Mentioned
    95 Post(s)
    Quoted
    717 Post(s)

    Default



    Remember children, a singleton pool is a great pool to have.

  17. #67
    Join Date
    Jan 2012
    Posts
    1,104
    Mentioned
    18 Post(s)
    Quoted
    211 Post(s)

    Default

    I found a problem with my client and since I used this tutorial as a base for the keylistener of my client, I will ask for help here.

    For some of my users canvas.getKeyListeners() returns with an empty array. Because of this the sendKeys() function wont work.

    I couldnt find the source of this problem yet, some of them have win7, win8 and java 1.7, java 1.8.

    I will include some code here:
    Code:
    public ClientKeyListener(Client client) {
    	this.client = client;
    }
    
    public void setCanvas(Canvas canvas) { //this is called after the constructor
    	this.canvas = canvas;
    	keyListeners = new ArrayList<>();
    	keyListeners.addAll(Arrays.asList(canvas.getKeyListeners()));
    	for (KeyListener listener : canvas.getKeyListeners()) {
    		canvas.removeKeyListener(listener);
    	}
    	canvas.addKeyListener(this);
    	System.out.println("keyListeners size: " + keyListeners.size()); //this will print out value 0 on some computers 
    }
    
    public void keyTyped(KeyEvent e) {
    	System.out.println("keyTyped: " + e.getKeyChar() + " " + e.getKeyCode());
    	
    	if (e.getSource() == client.getApplet()) {
    	    e.setSource(canvas);
    	    for (KeyListener listener : keyListeners) {
    			listener.keyTyped(e);
    	    }
    	} 
    }
    Thank you in advance, and Merry Xmas!

  18. #68
    Join Date
    Mar 2012
    Location
    127.0.0.1
    Posts
    3,383
    Mentioned
    95 Post(s)
    Quoted
    717 Post(s)

    Default

    Quote Originally Posted by Shatterhand View Post
    I found a problem with my client and since I used this tutorial as a base for the keylistener of my client, I will ask for help here.

    For some of my users canvas.getKeyListeners() returns with an empty array. Because of this the sendKeys() function wont work.

    I couldnt find the source of this problem yet, some of them have win7, win8 and java 1.7, java 1.8.

    I will include some code here:
    Code:
    public ClientKeyListener(Client client) {
    	this.client = client;
    }
    
    public void setCanvas(Canvas canvas) { //this is called after the constructor
    	this.canvas = canvas;
    	keyListeners = new ArrayList<>();
    	keyListeners.addAll(Arrays.asList(canvas.getKeyListeners()));
    	for (KeyListener listener : canvas.getKeyListeners()) {
    		canvas.removeKeyListener(listener);
    	}
    	canvas.addKeyListener(this);
    	System.out.println("keyListeners size: " + keyListeners.size()); //this will print out value 0 on some computers 
    }
    
    public void keyTyped(KeyEvent e) {
    	System.out.println("keyTyped: " + e.getKeyChar() + " " + e.getKeyCode());
    	
    	if (e.getSource() == client.getApplet()) {
    	    e.setSource(canvas);
    	    for (KeyListener listener : keyListeners) {
    			listener.keyTyped(e);
    	    }
    	} 
    }
    Thank you in advance, and Merry Xmas!
    Are you making sure the canvas isn't null before you run things on it?

    Are you properly filling 'this' with listeners?
    Check both.

  19. #69
    Join Date
    Jan 2012
    Posts
    1,104
    Mentioned
    18 Post(s)
    Quoted
    211 Post(s)

    Default

    Quote Originally Posted by NKN View Post
    Are you making sure the canvas isn't null before you run things on it?

    Are you properly filling 'this' with listeners?
    Check both.
    Yes, there is a waiting loop for canvas getting ready.

    I add this class for the Frame's contentPane. All this works for me, only doesnt work for some of my users.

  20. #70
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    Quote Originally Posted by Shatterhand View Post
    Yes, there is a waiting loop for canvas getting ready.

    I add this class for the Frame's contentPane. All this works for me, only doesnt work for some of my users.
    The custom canvas should call a function whenever it is changed/refreshed. This function will have to be quick and do all updating fast (fix listeners, update variables, etc). It will be synchronous with the canvas thread (don't thread the function).
    I am Ggzz..
    Hackintosher

  21. #71
    Join Date
    Jan 2012
    Posts
    1,104
    Mentioned
    18 Post(s)
    Quoted
    211 Post(s)

    Default

    Quote Originally Posted by Brandon View Post
    The custom canvas should call a function whenever it is changed/refreshed. This function will have to be quick and do all updating fast (fix listeners, update variables, etc). It will be synchronous with the canvas thread (don't thread the function).
    Im sorry I dont understand you. Could you explain it please?

    I dont do changes on the canvas, only when replacing the client in the frame, but then I will make a new ClientKeyListener and pass the client/canvas to it.

    I dont understand why it is working for me right now, but for some friends it doesnt.

  22. #72
    Join Date
    Jan 2012
    Posts
    1,104
    Mentioned
    18 Post(s)
    Quoted
    211 Post(s)

    Default

    Solved my problem in the previous posts. On some computers (it happened on my laptop too) the game loaded up so slow that the time the Canvas stopped being null wasnt the same when the Canvas's keylisteners were created. Added an extra check for this and now it works fine.

  23. #73
    Join Date
    Oct 2014
    Posts
    12
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Nice tutorial, will be looking into it more soon.

  24. #74
    Join Date
    Apr 2015
    Posts
    1
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    For some reason the drawn string doesn't appear after launching the example in your .zip file, am I doing something wrong?

    The applet just simply looks like this http : // i.imgur.com/ aL94FuJ.png, without the "I hope you enjoy this tutorial so far. This example demonstrates"...

    I feel like it has something to do with the Canvas not having been implemented correctly on my side, since debugging with a println in drawGraphics (Client.java) doesn't show anything.
    EDIT: getGraphics() in Canvas.java doesn't print anything when adding a println either.

    EDIT: Ahahaha, I read the last step thoroughly this time and realised that I need to xboot, oh my god.. I literally sat here for 2 hours trying to find out what was wrong..
    Last edited by Lotto320; 04-06-2015 at 06:40 PM.

  25. #75
    Join Date
    May 2013
    Posts
    46
    Mentioned
    0 Post(s)
    Quoted
    24 Post(s)

    Default

    this is really good i would love to talk to the brains of this operation

Page 3 of 6 FirstFirst 12345 ... LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •