diff --git a/main.js b/main.js index 8c8e4687b9694713dcf387fdda0d2d09cc11e868..915a7dd39ceea5c6fc7d0b343b927e304c618c21 100644 --- a/main.js +++ b/main.js @@ -2,6 +2,7 @@ const superPanel = require("./panel-window"); const os = require("os"); const isMacOS = os.type() === "Darwin"; +const isLinux = os.type() === "Linux"; const arch = process.arch; const getFilePathFromClipboard = (clipboard) => { @@ -71,7 +72,8 @@ const getFilePathFromClipboard = (clipboard) => { } function getSelectedContent(clipboard) { - const robot = os.type() === "Darwin" ? require(`./robot/darwin/${arch}/robotjs`) : require("./robot/win/robotjs"); + const robot = os.type() === "Darwin" ? require(`./robot/darwin/${arch}/robotjs`) + : ( os.type() === "Linux" ? require("./robot/linux/x64/robotjs") : require("./robot/win/robotjs") ); return new Promise((resolve) => { // todo 缓存文件 @@ -107,7 +109,7 @@ const getMouse = () => { } const getPos = (screen, point) => { - return isMacOS ? point : screen.screenToDipPoint({x: point.x, y: point.y}); + return isMacOS || isLinux ? point : screen.screenToDipPoint({x: point.x, y: point.y}); } const getPermission = () => { diff --git a/robot/linux/x64/robotjs/index.js b/robot/linux/x64/robotjs/index.js new file mode 100644 index 0000000000000000000000000000000000000000..94a0f7b458248c92efc5968d1467956623d6c42c --- /dev/null +++ b/robot/linux/x64/robotjs/index.js @@ -0,0 +1,36 @@ +var robotjs = require('./robotjs.node'); + +module.exports = robotjs; + +module.exports.screen = {}; + +function bitmap(width, height, byteWidth, bitsPerPixel, bytesPerPixel, image) +{ + this.width = width; + this.height = height; + this.byteWidth = byteWidth; + this.bitsPerPixel = bitsPerPixel; + this.bytesPerPixel = bytesPerPixel; + this.image = image; + + this.colorAt = function(x, y) + { + return robotjs.getColor(this, x, y); + }; + +} + +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(); + } + + return new bitmap(b.width, b.height, b.byteWidth, b.bitsPerPixel, b.bytesPerPixel, b.image); +}; diff --git a/robot/linux/x64/robotjs/robotjs.node b/robot/linux/x64/robotjs/robotjs.node new file mode 100644 index 0000000000000000000000000000000000000000..0428a0f48c5a93b5c08654baa25b6bbecb908c1b Binary files /dev/null and b/robot/linux/x64/robotjs/robotjs.node differ