Add Chat Spammer

This commit is contained in:
Marcel Schwarz 2019-08-09 06:30:11 +02:00
parent 8b5edde66b
commit 4b0a539906
13 changed files with 214 additions and 4 deletions

View File

@ -1,4 +1,4 @@
#Fri, 09 Aug 2019 06:24:54 +0200
#Fri, 09 Aug 2019 06:29:16 +0200
D\:\\Git-Repos\\java-fx-8-samples=

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.*?>
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<Pane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="262.0" prefWidth="266.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="chatspammer.LayoutController">
<children>
<TextField fx:id="tfSpamtext" layoutX="97.0" layoutY="14.0" prefHeight="15.0" prefWidth="150.0" />
<Label layoutX="16.0" layoutY="18.0" prefWidth="80.0" text="Spam Text" />
<Slider fx:id="slSpamDelay" layoutX="97.0" layoutY="55.0" majorTickUnit="20.0" minorTickCount="1" prefHeight="15.0" prefWidth="150.0" showTickLabels="true" showTickMarks="true" snapToTicks="true" value="10.0" />
<Label layoutX="16.0" layoutY="54.0" prefWidth="80.0" text="Spam Delay" />
<Button fx:id="btnStart" layoutX="16.0" layoutY="104.0" mnemonicParsing="false" onAction="#handleStart" prefHeight="25.0" prefWidth="235.0" text="Start Spamming" />
<Button fx:id="btnStop" layoutX="16.0" layoutY="136.0" mnemonicParsing="false" onAction="#handleStop" prefHeight="25.0" prefWidth="235.0" text="Stop Spamming" />
<ProgressIndicator fx:id="piRunning" layoutX="108.0" layoutY="170.0" />
<Label fx:id="lblRunning" layoutX="111.0" layoutY="231.0" text="Running" />
</children>
</Pane>

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -4,7 +4,7 @@
function launchApplication(jnlpfile) {
dtjava.launch( {
url : 'java-fx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3I+bXNjaHc8L3ZlbmRvcj4NCiAgICA8ZGVzY3JpcHRpb24+bnVsbDwvZGVzY3JpcHRpb24+DQogICAgPG9mZmxpbmUtYWxsb3dlZC8+DQogIDwvaW5mb3JtYXRpb24+DQogIDxyZXNvdXJjZXM+DQogICAgPGoyc2UgdmVyc2lvbj0iMS42KyIgaHJlZj0iaHR0cDovL2phdmEuc3VuLmNvbS9wcm9kdWN0cy9hdXRvZGwvajJzZSIvPg0KICAgIDxqYXIgaHJlZj0iamF2YS1meC04LXNhbXBsZXMuamFyIiBzaXplPSIyMDc4ODIiIGRvd25sb2FkPSJlYWdlciIgLz4NCiAgPC9yZXNvdXJjZXM+DQogIDxqZng6amF2YWZ4LWRlc2MgIHdpZHRoPSI4MDAiIGhlaWdodD0iNjAwIiBtYWluLWNsYXNzPSJ1dGlscy5SdW5uZXIiICBuYW1lPSJqYXZhLWZ4LTgtc2FtcGxlcyIgLz4NCiAgPHVwZGF0ZSBjaGVjaz0iYWx3YXlzIi8+DQo8L2pubHA+DQo='
},
{
javafx : '8.0+'
@ -24,7 +24,7 @@
placeholder : 'javafx-app-placeholder',
width : '800',
height : '600',
jnlp_content : 'PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjxqbmxwIHNwZWM9IjEuMCIgeG1sbnM6amZ4PSJodHRwOi8vamF2YWZ4LmNvbSIgaHJlZj0iamF2YS1meC04LXNhbXBsZXMuam5scCI+DQogIDxpbmZvcm1hdGlvbj4NCiAgICA8dGl0bGU+amF2YS1meC04LXNhbXBsZXM8L3RpdGxlPg0KICAgIDx2ZW5kb3I+bXNjaHc8L3ZlbmRvcj4NCiAgICA8ZGVzY3JpcHRpb24+bnVsbDwvZGVzY3JpcHRpb24+DQogICAgPG9mZmxpbmUtYWxsb3dlZC8+DQogIDwvaW5mb3JtYXRpb24+DQogIDxyZXNvdXJjZXM+DQogICAgPGoyc2UgdmVyc2lvbj0iMS42KyIgaHJlZj0iaHR0cDovL2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W1lPSJqYXZhLWZ4LTgtc2FtcGxlcyIgLz4NCiAgPHVwZGF0ZSBjaGVjaz0iYWx3YXlzIi8+DQo8L2pubHA+DQo='
},
{
javafx : '8.0+'

Binary file not shown.

View File

@ -8,7 +8,7 @@
</information>
<resources>
<j2se version="1.6+" href="http://java.sun.com/products/autodl/j2se"/>
<jar href="java-fx-8-samples.jar" size="203338" download="eager" />
<jar href="java-fx-8-samples.jar" size="207882" download="eager" />
</resources>
<jfx:javafx-desc width="800" height="600" main-class="utils.Runner" name="java-fx-8-samples" />
<update check="always"/>

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.*?>
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<Pane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="262.0" prefWidth="266.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="chatspammer.LayoutController">
<children>
<TextField fx:id="tfSpamtext" layoutX="97.0" layoutY="14.0" prefHeight="15.0" prefWidth="150.0" />
<Label layoutX="16.0" layoutY="18.0" prefWidth="80.0" text="Spam Text" />
<Slider fx:id="slSpamDelay" layoutX="97.0" layoutY="55.0" majorTickUnit="20.0" minorTickCount="1" prefHeight="15.0" prefWidth="150.0" showTickLabels="true" showTickMarks="true" snapToTicks="true" value="10.0" />
<Label layoutX="16.0" layoutY="54.0" prefWidth="80.0" text="Spam Delay" />
<Button fx:id="btnStart" layoutX="16.0" layoutY="104.0" mnemonicParsing="false" onAction="#handleStart" prefHeight="25.0" prefWidth="235.0" text="Start Spamming" />
<Button fx:id="btnStop" layoutX="16.0" layoutY="136.0" mnemonicParsing="false" onAction="#handleStop" prefHeight="25.0" prefWidth="235.0" text="Stop Spamming" />
<ProgressIndicator fx:id="piRunning" layoutX="108.0" layoutY="170.0" />
<Label fx:id="lblRunning" layoutX="111.0" layoutY="231.0" text="Running" />
</children>
</Pane>

View File

@ -0,0 +1,115 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package chatspammer;
import java.awt.AWTException;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.datatransfer.StringSelection;
import java.awt.event.KeyEvent;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.ProgressIndicator;
import javafx.scene.control.Slider;
import javafx.scene.control.TextField;
/**
*
* @author mschw
*/
public class LayoutController implements Initializable {
//Variables
Robot robot;
MyLoop spammer = new MyLoop(10);
volatile boolean shouldRun = false;
@FXML
private TextField tfSpamtext;
@FXML
private Slider slSpamDelay;
@FXML
private Button btnStart;
@FXML
private Button btnStop;
@FXML
private ProgressIndicator piRunning;
@FXML
private Label lblRunning;
@Override
public void initialize(URL url, ResourceBundle rb) {
try {
robot = new Robot();
} catch (AWTException ex) {
System.err.println("Robot konnte nicht erstellt werden");
}
changeProgress(false);
}
@FXML
private void handleStart(ActionEvent event) {
if (!tfSpamtext.getText().isEmpty()) {
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(tfSpamtext.getText()), null);
if (slSpamDelay.getValue() < 10) {
spammer = new MyLoop(10);
} else {
spammer = new MyLoop((int) slSpamDelay.getValue());
}
shouldRun = true;
spammer.start();
changeProgress(true);
}
}
@FXML
private void handleStop(ActionEvent event) {
if (spammer != null) {
shouldRun = false;
spammer = null;
changeProgress(false);
}
}
private void changeProgress(boolean b) {
piRunning.setVisible(b);
lblRunning.setVisible(b);
}
private class MyLoop extends Thread {
final int delay;
public MyLoop(int delay) {
this.delay = delay;
}
@Override
public void run() {
while (shouldRun) {
try {
robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_V);
robot.keyRelease(KeyEvent.VK_CONTROL);
robot.keyRelease(KeyEvent.VK_V);
robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);
sleep(delay);
} catch (InterruptedException ex) {
}
}
}
}
}

49
src/chatspammer/Main.java Normal file
View File

@ -0,0 +1,49 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package chatspammer;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import utils.JFXUtil;
/**
*
* @author mschw
*/
public class Main extends Application {
@Override
public void start(Stage stage) {
Parent root = null;
try {
root = FXMLLoader.load(getClass().getResource("Layout.fxml"));
} catch (IOException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
Scene scene = new Scene(root);
stage.setResizable(false);
stage.setOnCloseRequest(JFXUtil::stopAllThreadsOnWindowClose);
stage.setScene(scene);
stage.show();
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}
}

View File

@ -140,6 +140,10 @@ public class Runner extends Application{
btn20.setOnAction(event -> new taschenrechnerkomma.Main().start(new Stage()));
gridpane.add(btn20, 1, 9);
Button btn24 = new Button("Start Chat Spammer");
btn24.setOnAction(event -> new chatspammer.Main().start(new Stage()));
gridpane.add(btn24, 2, 9);
ScrollPane root = new ScrollPane(gridpane);
Scene scene = new Scene(root, 600, 400);