-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathoutput.js
More file actions
35 lines (28 loc) · 921 Bytes
/
output.js
File metadata and controls
35 lines (28 loc) · 921 Bytes
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
var fs = require('fs');
var robot = require('robotjs');
var sleep = require('sleep');
var data = fs.readFileSync('bot.txt');
var conversion= require('./conversion');
var captureMotion = JSON.parse(data);
//start imitating user
//skip the data used to initialize
for(var j= 1; j< captureMotion.length; j++) {
motion = captureMotion[j];
sleep.msleep(motion.interval);
robot.moveMouse(motion.x, motion.y);
motionEvent = motion.rawcode;
if(motionEvent == 127) {
robot.mouseClick();
} else if(motionEvent== 128) {
preMotion = captureMotion[j-1];
if(preMotion.rawcode == 128) {
robot.mouseToggle('up','left');
} else {
robot.mouseToggle('down','left');
}
} else {
tapKey = conversion.keycodeConversion( motionEvent.toString().toLowerCase());
robot.keyTap(tapKey);
}
};
return console.log('\nprogram ended');