Making a simple Java bot

Discussion in 'Programming General' started by somanayr, Apr 30, 2010.

Making a simple Java bot
  1. Unread #1 - Apr 30, 2010 at 9:50 PM
  2. somanayr
    Joined:
    Apr 25, 2010
    Posts:
    114
    Referrals:
    0
    Sythe Gold:
    0

    somanayr Active Member

    Making a simple Java bot

    Hi!
    I'm making a spam bot for Palringo chat. (if my motives are important, let me know)
    I've learned the Robot class. What I have now is a bot that spells out "chaos" and presses enter. It loops 1000 times. Here is my map for each new version:
    1) GUI that allows you to close at any time and allows you to specify number of loops
    2) Add a mouse finder function that will allow me to ask the user to join and exit a specified group so that I can join and exit repeatedly making me next to impossible to ban
    3) Add the ability to have your own message spelled out one letter at a time
    4) Allow personal messages to be entered all at once
    5) Add a function to figure out when the account is banned and create a new account with a proxy in this event.

    To achieve my next goal, I have to learn how to make a REALLY simple GUI and how to make a text entry box and a text box to explain what is to be put in the box. If it's important, I want the user to confirm by pressing the "enter" key.
    Also, I want the user to be able to close the GUI.
    I am going to go do some more research on my own. If anyone has any sites to recommend for this, that would be awesome.

    -----EDIT-----
    Will I need to make a new class for a GUI? I don't have any practice with multiple classes, lol. I can always ask my teacher on Monday.
     
  3. Unread #2 - Apr 30, 2010 at 9:59 PM
  4. Jimmy
    Joined:
    Jun 24, 2008
    Posts:
    2,421
    Referrals:
    10
    Sythe Gold:
    25

    Jimmy Ghost
    Retired Sectional Moderator $5 USD Donor

    Making a simple Java bot

    If you are looking into making a GUI in Java, using swing components would be ideal.

    Sun Tutorials on Swing: http://java.sun.com/docs/books/tutorial/uiswing/

    Also, to address your question about creating multiple classes, no, although subclassing JFrame and adding components is commonly done, you can easily simply create a new instance of the JFrame class and then add whatever swing components you want to it.
     
  5. Unread #3 - Apr 30, 2010 at 10:13 PM
  6. somanayr
    Joined:
    Apr 25, 2010
    Posts:
    114
    Referrals:
    0
    Sythe Gold:
    0

    somanayr Active Member

    Making a simple Java bot

    Is there any benefit to making it a separate class? For my level, there probably isn't. But is it just to remove clutter?
     
  7. Unread #4 - Apr 30, 2010 at 10:18 PM
  8. Jimmy
    Joined:
    Jun 24, 2008
    Posts:
    2,421
    Referrals:
    10
    Sythe Gold:
    25

    Jimmy Ghost
    Retired Sectional Moderator $5 USD Donor

    Making a simple Java bot

    Yeah, pretty much. You'd also have access to the protected methods of the JFrame class should you choose to subclass it, although you should fair fine without these.
     
  9. Unread #5 - Apr 30, 2010 at 10:24 PM
  10. Jimmy
    Joined:
    Jun 24, 2008
    Posts:
    2,421
    Referrals:
    10
    Sythe Gold:
    25

    Jimmy Ghost
    Retired Sectional Moderator $5 USD Donor

    Making a simple Java bot

    Yeah, pretty much. You'd also have access to the protected methods of the JFrame class should you choose to subclass it, although you should fair fine without these.
     
  11. Unread #6 - Apr 30, 2010 at 11:03 PM
  12. somanayr
    Joined:
    Apr 25, 2010
    Posts:
    114
    Referrals:
    0
    Sythe Gold:
    0

    somanayr Active Member

    Making a simple Java bot

  13. Unread #7 - May 1, 2010 at 11:43 AM
  14. Jimmy
    Joined:
    Jun 24, 2008
    Posts:
    2,421
    Referrals:
    10
    Sythe Gold:
    25

    Jimmy Ghost
    Retired Sectional Moderator $5 USD Donor

    Making a simple Java bot

  15. Unread #8 - Jun 1, 2010 at 7:07 PM
  16. noob532
    Joined:
    Jan 7, 2010
    Posts:
    29
    Referrals:
    0
    Sythe Gold:
    1

    noob532 Member

    Making a simple Java bot

    java.awt.Robot doesnt properly map Ascii (character codes) to key codes. Its a pain to make a function to translate them. Here's mine (yes i know it should use hashmaps to get the key codes I wrote this long ago :p)

    Code:
    public int ascii2VK(int ascii) {
    		int keyCode = -1;
    		if((ascii >= 48 && ascii <=57) || (ascii >= 65 && ascii <=90)) {
    			keyCode = ascii;
    		} 
    		else if(ascii >= 97 && ascii <= 122) {
    			keyCode = ascii - 32;
    		}
    		else if(ascii == 10) {
    			keyCode = KeyEvent.VK_ENTER;
    		}
    		else if(ascii == 32) {
    			keyCode = KeyEvent.VK_SPACE;
    		}
    		else if(ascii == 33) {
    			keyCode = 49;
    		}
    		else if(ascii == 34) {
    			keyCode = KeyEvent.VK_QUOTE;
    		}
    		else if(ascii == 35) {
    			keyCode = 51;
    		}
    		else if(ascii == 36) {
    			keyCode = 52;
    		}
    		else if(ascii == 37) {
    			keyCode = 53;
    		}
    		else if(ascii == 38) {
    			keyCode = 55;
    		}
    		else if(ascii == 39) {
    			keyCode = KeyEvent.VK_QUOTE;
    		}
    		else if(ascii == 40) {
    			keyCode = 57;
    		}
    		else if(ascii == 41) {
    			keyCode = 48;
    		}
    		else if(ascii == 42) {
    			keyCode = 56;
    		}
    		// i <3 the creator of ascii/vk codes :]
    		else if(ascii == 43) {
    			keyCode = KeyEvent.VK_EQUALS;
    		}
    		else if(ascii == 44) {
    			keyCode = KeyEvent.VK_COMMA;
    		}
    		else if(ascii == 44) {
    			keyCode = KeyEvent.VK_COMMA;
    		}
    		else if(ascii == 45) {
    			keyCode = KeyEvent.VK_MINUS;
    		}
    		else if(ascii == 46) {
    			keyCode = KeyEvent.VK_PERIOD;
    		}
    		else if(ascii == 47) {
    			keyCode = KeyEvent.VK_SLASH;
    		}
    		else if(ascii == 58) {
    			keyCode = KeyEvent.VK_SEMICOLON;
    		}
    		else if(ascii == 59) {
    			keyCode = KeyEvent.VK_SEMICOLON;
    		}
    		else if(ascii == 60) {
    			keyCode = KeyEvent.VK_COMMA;
    		}
    		else if(ascii == 61) {
    			keyCode = KeyEvent.VK_EQUALS;
    		}
    		else if(ascii == 62) {
    			keyCode = KeyEvent.VK_PERIOD;
    		}
    		else if(ascii == 63) {
    			keyCode = KeyEvent.VK_SLASH;
    		}
    		else if(ascii == 64) {
    			keyCode = 50;
    		}
    		else if(ascii == 64) {
    			keyCode = 50;
    		}
    		else if(ascii == 91) {
    			keyCode = KeyEvent.VK_OPEN_BRACKET;
    		}
    		else if(ascii == 92) {
    			keyCode = KeyEvent.VK_BACK_SLASH;
    		}
    		else if(ascii == 93) {
    			keyCode = KeyEvent.VK_CLOSE_BRACKET;
    		}
    		else if(ascii == 94) {
    			keyCode = 54;
    		}
    		else if(ascii == 95) {
    			keyCode = KeyEvent.VK_MINUS;
    		}
    		else if(ascii == 123) {
    			keyCode = KeyEvent.VK_OPEN_BRACKET;
    		}
    		else if(ascii == 124) {
    			keyCode = KeyEvent.VK_BACK_SLASH;
    		}
    		else if(ascii == 125) {
    			keyCode = KeyEvent.VK_CLOSE_BRACKET;
    		}
    		else {
    			System.out.println("this key code has not been implemented");
    		}
    		return keyCode;
    	}
    	
    	/**
    	 * Checks to see if the key needs shift held down
    	 * @param ascii The ascii value of the key
    	 * @return Returns true if shift needs to be held to type key
    	 */
    	public boolean needsShift(int ascii) {
    		boolean ret = false;
    		if (ascii >= 65 && ascii <=90)
    			ret = true;
    		else if (ascii >= 33 && ascii <= 38)
    			ret = true;
    		else if (ascii >= 40 && ascii <= 43)
    			ret = true;
    		else if (ascii >= 40 && ascii <= 43)
    			ret = true;
    		else if (ascii == 58)
    			ret = true;
    		else if (ascii == 60)
    			ret = true;
    		else if (ascii >= 62 && ascii <= 64)
    			ret = true;
    		else if (ascii == 94)
    			ret = true;
    		else if (ascii == 95)
    			ret = true;
    		else if (ascii >= 123 && ascii <= 125)
    			ret = true;
    		return ret;
    	}
    	
    	/**
    	 * Generates key events to type the character given.
    	 * @param ascii The ascii value of the character to be typed
    	 */
    	 public void sendKey(int ascii) {
    	 	if (needsShift(ascii)) {
    	 		robot.keyPress(KeyEvent.VK_SHIFT);
    			robot.delay(random(random(11,16),random(16,28)));
        		robot.keyPress(ascii2VK(ascii));
    			robot.delay(random(random(11,16),random(16,28)));
    			robot.keyRelease(ascii2VK(ascii));
    			robot.delay(random(random(11,16),random(16,28)));
    			robot.keyRelease(KeyEvent.VK_SHIFT);
    		}
    		else {
    			robot.keyPress(ascii2VK(ascii));
    			robot.delay(random(random(11,16),random(16,28)));
    			robot.keyRelease(ascii2VK(ascii));
    		}
    	}
    EDIT: Probably easier just to use keyevent though, I didn't realize it can be used to translate
     
  17. Unread #9 - Jun 2, 2010 at 2:49 PM
  18. somanayr
    Joined:
    Apr 25, 2010
    Posts:
    114
    Referrals:
    0
    Sythe Gold:
    0

    somanayr Active Member

    Making a simple Java bot

    haha. the thing I wrote is a little more user friendly :)
     
  19. Unread #10 - Sep 2, 2010 at 12:45 AM
  20. chrisadam12
    Joined:
    Sep 2, 2010
    Posts:
    2
    Referrals:
    0
    Sythe Gold:
    0

    chrisadam12 Newcomer

    Making a simple Java bot

    Robots or bots are automatic processes which interact with Wikipedia as though they were human editors. This page attempts to explain how to carry out the development of a bot for use on Wikipedia. The explanation is geared mainly towards those who have some prior programming experience, but are unsure of how to apply this knowledge to creating a Wikipedia bot.

    There are already a number of bots running on Wikipedia. Many of these bots publish their source code, which can sometimes be reused with little additional development time. In addition, there are a number of semi-bots available to anyone. Most of these take the form of enhanced web browsers with Wikipedia-specific functionality. The most popular of these is AutoWikiBrowser; see Wikipedia:Tools/Editing tools for a complete list.
    If you have no previous programming experience, it may be simpler to ask an existing bot to do the job, or ask others to develop a bot for you. These requests can be made at Wikipedia:Bot requests. If you wish to write a new bot anyway, be aware that learning a programming language is a non-trivial task. However, it is not black magic – anyone can learn how to program with sufficient time and effort. Good luck!
    If you decide to create a bot, planning is crucial to obtain an error-free, efficient, and effective program. The following initial considerations are important:
    Will the bot be manually assisted or fully automated?
    Will you create the bot alone, or with the help of other programmers?
    What language will be used to implement the bot?
    Will the bot's requests, edits, or other actions be logged? If so, will the logs be stored on local media, or on wiki pages?
    Will the bot run inside a web browser (for example, written in Javascript), or will it be a standalone program?
    If the bot is a standalone program, will it run on your local computer, or on a remote server such as the Wikimedia Toolserver?
    If the bot runs on a remote server, will other editors be able to operate the bot or start it running?



    ______________________________________________________



    Want to get-on Google's first page and loads of traffic to your website? Hire a SEO specialist from Ocean Groups seo specialist
     
  21. Unread #11 - Mar 1, 2011 at 8:44 AM
  22. AwT
    Joined:
    May 4, 2007
    Posts:
    45
    Referrals:
    0
    Sythe Gold:
    0

    AwT Member

    Making a simple Java bot

    Deleted
     
< What was used to make this website? | Just learning >

Users viewing this thread
1 guest


 
 
Adblock breaks this site