Adblock breaks this site

[source] GUI AutoSpammer in JAVA

Discussion in 'Programming General' started by slashshot007, Nov 15, 2007.

  1. slashshot007

    slashshot007 Active Member

    Joined:
    May 6, 2006
    Posts:
    164
    Referrals:
    0
    Sythe Gold:
    0
    [source] GUI AutoSpammer in JAVA

    well i'm learning TONS of stuff now, and I finally understand JAVA fairly well enough to say that this is pretty good.

    It took me 3 hours just to make this (It may sound bad, but i'm not familiar with java yet), so if you use this, be sure to give credit.

    Code:
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    
    public class AutoSpammer{
    	
    	private static int interval;
    	private static Timer timerMain;
    	private static JTextField txtSpam;
    	private static JTextField txtInterval;
    	private static JButton btnStart;
    	private static JButton btnStop;
    	
    	public static void main(String[]args){
    		ActionListener taskSpam = new ActionListener(){
    			public void actionPerformed(ActionEvent evt) {
    				sendkeys(txtSpam.getText());
    			  }
    		};
    		ActionListener taskStartTimer = new ActionListener(){
    			public void actionPerformed(ActionEvent evt){
    				timerMain.setDelay(Integer.parseInt(txtInterval.getText()));
    				timerMain.start();
    				btnStart.setEnabled(false);
    				btnStop.setEnabled(true);
    				txtInterval.setEnabled(false);
    			}
    		};
    		ActionListener taskStopTimer = new ActionListener(){
    			public void actionPerformed(ActionEvent evt){
    				timerMain.stop();
    				btnStart.setEnabled(true);
    				btnStop.setEnabled(false);
    				txtInterval.setEnabled(true);
    			}
    		};
    
    		btnStart = new JButton("Start");
    		btnStop = new JButton("Stop");
    		JLabel lbl1 = new JLabel("Enter Text:");
    		JLabel lbl2 = new JLabel("Interval:");
    		timerMain = new Timer(1,taskSpam);
    		txtSpam = new JTextField("Java AutoSpammer", 13);
    		txtInterval = new JTextField("3000",3);
    		
    		btnStart.addActionListener(taskStartTimer);
    		btnStop.addActionListener(taskStopTimer);
    		btnStop.setEnabled(false);
    		
    		JPanel intervalpane = new JPanel();
    		intervalpane.add(lbl2,BorderLayout.EAST);
    		intervalpane.add(txtInterval,BorderLayout.WEST);
    		
    		JPanel bottompane = new JPanel();
    		bottompane.add(btnStart,BorderLayout.EAST);
    		bottompane.add(btnStop,BorderLayout.CENTER);
    		bottompane.add(intervalpane,BorderLayout.WEST);
    		
    		JPanel toppane = new JPanel();
    		toppane.add(lbl1,BorderLayout.EAST);
    		toppane.add(txtSpam,BorderLayout.NORTH);
    		
    		JPanel pane = new JPanel(new BorderLayout());
    		pane.add(toppane,BorderLayout.NORTH);
    		pane.add(bottompane,BorderLayout.SOUTH);
    		
    		JFrame frame = new JFrame("Java Spammer");
    		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    		frame.setContentPane(pane);
    		frame.pack();
    		frame.setResizable(false);
    		frame.setVisible(true);
    	  }
    	
    	private static void sendkeys(String text) {
       		try {
    	   		Robot robot = new Robot();
    	   		text = text.toUpperCase();
    	   		for(int i = 0; i < text.length(); i++)
    		   		robot.keyPress(text.charAt(i));
    		robot.keyPress(KeyEvent.VK_ENTER);
       		}catch(java.awt.AWTException exc) {
    	   		System.out.println("error");
       		}
    	}
    }
    it all goes into one java file called AutoSpammer. if you didn't know that from looking at the code, then you probably don't deserve the source.
     
  2. Michael3455

    Michael3455 Active Member

    Joined:
    Sep 11, 2005
    Posts:
    134
    Referrals:
    0
    Sythe Gold:
    0
    [source] GUI AutoSpammer in JAVA

    Very nice, very nice. I'm also learning Java, and was thinking about making an Auto spammer. Guess I won't now, I'll just use yours :D

    P.S. If you wanted to make a really cool thing that would help out a lot of important people (Namely me, :p) you could make a Colour searching function that works without a GUI. Which probably works exactly like it would with a gui, but oh well.
     
  3. Fate1

    Fate1 Apprentice
    Banned

    Joined:
    Apr 21, 2005
    Posts:
    773
    Referrals:
    2
    Sythe Gold:
    5
    [source] GUI AutoSpammer in JAVA

    Damn nice.. I'm learning java still, I dont understand the throw clause and catch clause... I have no idea when to use them.. but I just started gui and this could help me :D thanks.
     
  4. Michael3455

    Michael3455 Active Member

    Joined:
    Sep 11, 2005
    Posts:
    134
    Referrals:
    0
    Sythe Gold:
    0
    [source] GUI AutoSpammer in JAVA

    Fate: Basically, you use them each time an error. could happen that would close the program. The Try ... Catch simple try's to do one section of code, if it can't, instead of closing the program, it skips the code and goes to the next thing.

    It's just much better to catch the error, then to have code that closes down all the time.

    Oh, also, a lot of things require you to catch an exception, for instance the Robot Class. Of course, you can explicitly state that you don't want it caught though.
     
  5. fudgepack a

    fudgepack a Guest

    Referrals:
    0
    [source] GUI AutoSpammer in JAVA

    hey im also trying to learn java but i got this thing called net beans got it from some site it had a java writer on it but it wont let my write at all cause it says can not find class and im following the tuts perfectly dont know wut to do could u tell wut java writter u are useing or something like that i would luv to know this netbeans even had its own tut and it wasn't working for me XD so i think i just downloaded and installed a bogus writter so could u help me at least get started plz
     
  6. slashshot007

    slashshot007 Active Member

    Joined:
    May 6, 2006
    Posts:
    164
    Referrals:
    0
    Sythe Gold:
    0
    [source] GUI AutoSpammer in JAVA

    jcreator, and notepad
     
< can you send packets to rs client | Mouse mOvement Help >


 
 
Adblock breaks this site