前言
公司有一款 IM 聊天軟件,需要截圖功能。前同事寫一個 Go 語言的版本,BUG 太多了,功能也不好用。
我們找到了一個方法,微信 dll,同事包裝一下生成 exe 文件,我用 Node.js 去調(diào)用完成截圖。
- 第一步先用 Node 執(zhí)行微信封裝的 exe,然后會把截圖復(fù)制到剪切板
- 然后調(diào)用瀏覽把剪切板的內(nèi)容復(fù)制出來
var screen_window = execFile(__dirname + '/screen/PrintScr.exe')
screen_window.on('exit', function (code) {
// 執(zhí)行成功返回 1,返回 0 沒有截圖
if (code) mainWindow.webContents.paste()
})
截圖軟件 Git 地址: https://github.com/liangtongzhuo/electron_screenshot