-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.js
49 lines (42 loc) · 1.17 KB
/
bot.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
var robot = require("robotjs");
function getPointerPixel(span, callback) {
if (!(span.x && span.y)) {
span = {
'x': 0,
'y': 0
};
}
// Get mouse position.
var mouse = robot.getMousePos();
// Get pixel color in hex format.
var hex = robot.getPixelColor(mouse.x + span.x, mouse.y + span.y);
//console.log("#" + hex + " at x:" + mouse.x + " y:" + mouse.y);
if (callback) callback(hex);
}
setInterval(function() {
getPointerPixel(function(hex) {
if (hex == "535353" || hex == "e2e2e2" || hex == "909090" ||
hex == "b9b9b9" || hex == "f9ffff") {
console.log(hex)
robot.keyTap("up");
} else {
if (hex != "f7f7f7")
console.log(hex);
}
});
}, 1)
setInterval(function() {
getPointerPixel({
'x': -1,
'y': 0
}, function(hex) {
if (hex == "535353" || hex == "e2e2e2" || hex == "909090" ||
hex == "b9b9b9" || hex == "f9ffff") {
console.log(hex)
robot.keyTap("up");
} else {
if (hex != "f7f7f7")
console.log(hex);
}
});
}, 0)