Code Monkey home page Code Monkey logo

shortcut-capture's Introduction

shortcut-capture

electron shortcut capture plugin(electron 截图模块插件)。注意:1.1.x和1.0.x版本有API的改动,所以会有不兼容的地方,请参考API,1.1.x主要支持了窗口关闭不能结束应用的问题。参考nashaofu#4nashaofu#7

Install

NPM

Usage

import { app, globalShortcut } from 'electron'
import ShortcutCapture from 'shortcut-capture'

app.on('ready', () => {
  // 必须在ready之后初始化,否者会报错
  const shortcutCapture = new ShortcutCapture()
  globalShortcut.register('ctrl+alt+a', () => shortcutCapture.shortcutCapture())
  console.log(shortcutCapture)
  // 拿取截图后返回信息
  shortcutCapture.on('capture', ({ dataURL, bounds }) => console.log(dataURL, bounds))
})

app.on('window-all-closed', () => {
  if (process.platform !== 'darwin') {
    app.quit()
  }
})

Options

new ShortcutCapture({
  dirname: string,
  isUseClipboard: true
})
名称 类型 说明 默认值
dirname string 本插件所在文件夹,目的是使得插件能够正确引用资源,如窗口界面 path.join(app.getAppPath(), 'node_modules/shortcut-capture')
isUseClipboard boolean 是否使用剪切板,即是否把图片资源写入剪切板 true

Methods

名称 说明 参数 返回值
shortcutCapture 调用截图方法直接截图 - -

Events

名称 说明 回调参数
capture 截图确认后后调 dataURL-图片资源, bounds-截图区域信息

Screenshot

screenshot

TODOS

  • 截图区域移动
  • 截图区域大小调整
  • 主显示器切换支持,显示器变动支持
  • Mac 多显示器截图还存在问题
  • 对各个平台进行不同样式的显示,窗口大小等等,windows 平台已经完美支持,其他平台还需调整与优化

问题

  • 高分屏作为主显示器是截图质量很低,以低分屏作为主显示器时,截图效果较为理想

shortcut-capture's People

Contributors

nashaofu avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.