-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMouseKeyServer.java
More file actions
168 lines (147 loc) · 4.93 KB
/
MouseKeyServer.java
File metadata and controls
168 lines (147 loc) · 4.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
package com.company;
import java.awt.*;
import java.awt.event.*;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.net.ServerSocket;
import java.net.Socket;
public class MouseKeyServer {
Thread pos;
Thread click;
Thread scroll;
public MouseKeyServer(int port){
pos = new MousePosition(1001);
click = new MouseClick(1002);
scroll = new MouseScroll(1003);
pos.start();
System.out.println("ITFUCKINGWPORKS");
//click.start();
System.out.println("ITFUCKINGWPORKS");
//scroll.start();
System.out.println("ITFUCKINGWPORKS");
}
public MouseWheelListener getScroll(){
MouseScroll a = (MouseScroll) scroll;
return a.wheelListener;
}
public MouseListener getClick(){
MouseClick a = (MouseClick) click;
return a.listener;
}
public class MousePosition extends Thread {
ServerSocket a;
ObjectOutputStream out;
Socket client;
public MousePosition(int port){
System.out.println("Constructed call");
try {
a = new ServerSocket(port);
client = a.accept();
System.out.println("Accepted Client: " + port);
out = new ObjectOutputStream(client.getOutputStream());
} catch (IOException E){
System.out.println(E + "MouseScroll");
}
}
public void run() {
while(true) {
Point mp = GetMousePos();
System.out.println(mp.getX() + ", " + mp.getY());
try {
out.writeObject(mp);
} catch (IOException E) {
System.out.println(E);
}
}
}
public Point GetMousePos(){
return MouseInfo.getPointerInfo().getLocation();
}
}
public class MouseClick extends Thread {
String currentMove;
ServerSocket b;
ObjectOutputStream out;
Socket client;
public MouseClick(int port){
try {
b = new ServerSocket(port);
client = b.accept();
out = new ObjectOutputStream(client.getOutputStream());
} catch (IOException E){
System.out.println(E + "MouseClick");
}
}
public MouseListener listener = new MouseListener() {
@Override
public void mouseClicked(MouseEvent e) {
currentMove = e.getButton() + "Click";
System.out.println("Click");
}
@Override
public void mousePressed(MouseEvent e) {
currentMove = e.getButton() + "Press";
System.out.println("Press");
}
@Override
public void mouseReleased(MouseEvent e) {
currentMove = e.getButton() + "Release";
System.out.println("Release");
}
@Override
public void mouseEntered(MouseEvent e) {
currentMove = e.getButton() + "Enter";
System.out.println("Enter");
}
@Override
public void mouseExited(MouseEvent e) {
currentMove = e.getButton() + "Exit";
System.out.println("Exit");
}
};
public void run() {
while(true){
try {
if(currentMove != null) {
System.out.println(currentMove);
out.writeObject(currentMove);
}
currentMove = null;
} catch (IOException E){
}
}
}
}
public class MouseScroll extends Thread {
ServerSocket c;
ObjectOutputStream out;
Socket client;
int scrollUnits = 0;
MouseWheelListener wheelListener = new MouseWheelListener() {
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
scrollUnits = e.getUnitsToScroll();
}
};
public MouseScroll(int port){
try {
c = new ServerSocket(port);
client = c.accept();
out = new ObjectOutputStream(client.getOutputStream());
} catch (IOException E){
System.out.println(E + "MouseScroll");
}
}
public void run(){
while(true){
try {
// if(scrollUnits != 0) {
out.writeObject(scrollUnits);
// }
// scrollUnits = 0;
} catch (IOException E){
}
}
}
}
}