-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmakeMove.js
executable file
·43 lines (39 loc) · 1.05 KB
/
makeMove.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
#!/usr/bin/env node
var robot = require('robotjs'),
config = require('./config'),
boardConstraints = {
topLeft: {
x: 40,
y: 209
},
bottomRight: {
x: 461,
y: 630
},
boxWidth: 52
};
var move = process.argv[2];
if (move.length != 4)
process.exit(-1);
var move = {
start: config.moveToPosition(boardConstraints, move[0] + move[1]),
end: config.moveToPosition(boardConstraints, move[2] + move[3]),
};
console.log('move=', move);
robot.moveMouseSmooth(move.start.X, move.start.Y);
setTimeout(function() {
robot.mouseClick();
setTimeout(function() {
robot.mouseClick();
setTimeout(function() {
robot.mouseToggle('down');
setTimeout(function() {
// robot.dragMouse(move.end.X, move.end.Y);
robot.moveMouseSmooth(move.end.X, move.end.Y);
setTimeout(function() {
robot.mouseToggle('up');
}, 5);
}, 5);
}, 5);
}, 5);
}, 5);