Socket
Socket
Sign inDemoInstall

electron-screenshoter

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

electron-screenshoter

a electron screenshot util


Version published
Weekly downloads
3
increased by200%
Maintainers
1
Weekly downloads
 
Created
Source

electron-screenshoter

electron 截图插件

types electron platform

Usage

内网安装

yarn add electron-screenshoter

使用方式

主进程

const { initMain, close } = require('electron-screenshot');

app.on('ready', () => {
  const win = new BrowserWindow();
  initMain(win.webContents);

  // 新增快捷键取消截图
  Menu.setApplicationMenu(
    Menu.buildFromTemplate([
      {
        label: '编辑',
        submenu: [
          {
            accelerator: 'Esc',
            label: '取消截图',
            click: close
          }
        ]
      }
    ])
  );
});

注:传入 intMain 方法的参数为实际调用截图功能的渲染进程

渲染进程

const { screenshot } = require('electron-screenshot');

screenshot().then(({ base64 }) => {
  console.log('截图 base64 地址: ', base64);
});

Notice

windows 系统下使用 nircmd 程序捕捉桌面帧,为保证一致性,插件已将该可执行文件集成至项目中,打包时需要在 package.json 中增加以下配置:

{
  ...
  "build": {
    ...
    "asarUnpack": [
      "*.exe"
    ],
    ...
  }
  ...
}

详细参见:electron-builder-doc: Overridable per Platform Options

FAQs

Package last updated on 06 Jul 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc