-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
54 lines (48 loc) · 1.13 KB
/
index.js
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
var robot = require("robotjs");
var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);
http.listen(919, function(){
console.log('listening on 919');
});
var currentpos = robot.getMousePos();
var screenSize = robot.getScreenSize();
io.on("connection", (socket) => {
socket.on("start",data => {
currentpos = robot.getMousePos();
})
socket.on("move",data=> {
robot.moveMouse(currentpos.x + data.x, currentpos.y + data.y);
})
socket.on("ldown",() => {
robot.mouseToggle("down");
})
socket.on("lup",() => {
robot.mouseToggle("up");
})
socket.on("rdown",() => {
robot.mouseToggle("down","right")
})
socket.on("rup", () => {
robot.mouseToggle("up","right");
})
socket.on("key", key => {
if(key == "") return;
try {
robot.keyTap(key);
}
catch(e) {}
})
socket.on("log", data => {
console.log(data);
})
socket.on("abso", data => {
robot.moveMouse(screenSize.width * data.x, screenSize.height * data.y);
})
})
app.get("/", (req,res) => {
res.sendFile(__dirname + "/index.html")
})
app.get("/abso", (req,res) => {
res.sendFile(__dirname + "/abso.html")
})