1.0.0 • Published 2 years ago

yxlolxy-electron-plugins v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

yxlolxy-electron-plugins

Install

yarn add yxlolxy-electron-plugins
# Or with npm:
npm i yxlolxy-electron-plugins

Note: this package has a peerDependency of electron@^15.1.2, and only works in window10+

Usage

  1. import pkg into your main.js
// main.js of your electron app
const { useCapture, usePreview } = require('yxlolxy-electron-plugins')
let mainWindow = null;
...
app.whenReady().then(() => {
  ...
  useCapture(mainWindow) // transfer mainWindow to send message to mainWindow render process
  usePreview()
})
...
  1. events of capture
// renderer.js
// start the event
ipcRenderer.invoke('screen-capture', {
        type: 'start'
})
// handle the event
ipcRenderer.on('screen-capture', (e, url) => {
  // handle the url
  ...
})
// close the event,press ESC or click right button of your mouse
  1. events of preview
// renderer.js
// start the event
ipcRenderer.invoke('image-preview', {
        type: 'show',
        url:: '', // your image url
        filename: '' // your image origin filename
})

enjoy it!