-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathindex.js
37 lines (33 loc) · 1020 Bytes
/
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
const robotjs = require('node-gyp-build')(__dirname);
module.exports = robotjs;
module.exports.screen = {
get xDisplayName() {
return robotjs.getXDisplayName();
},
set xDisplayName(value) {
robotjs.setXDisplayName(value);
}
};
module.exports.screen.capture = function(x, y, width, height) {
// If coords have been passed, use them.
if (typeof x !== "undefined" && typeof y !== "undefined" && typeof width !== "undefined" && typeof height !== "undefined") {
b = robotjs.captureScreen(x, y, width, height);
} else {
b = robotjs.captureScreen();
}
const bitmap = {
width: b.width,
height: b.height,
byteWidth: b.byteWidth,
bitsPerPixel: b.bitsPerPixel,
bytesPerPixel: b.bytesPerPixel,
image: b.image,
};
bitmap.colorAt =(x, y) => {
return robotjs.getColor(bitmap, x, y);
};
return bitmap;
};
module.exports.screen.updateMetrics = function() {
robotjs.updateScreenMetrics();
};