minor updates to design
This commit is contained in:
parent
e1ccfb95a1
commit
7fcfe80d0a
|
@ -17,7 +17,7 @@
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<label id="screenshot-path">Path:</label><br>
|
<label id="screenshot-path">Path:</label><br>
|
||||||
<button id="path-button" class="btn btn-warning">Select Path</button><br>
|
<button id="path-button" class="btn btn-primary">Select Path</button><br>
|
||||||
<button id="screen-shot" class="btn btn-primary">Take Screenshot</button>
|
<button id="screen-shot" class="btn btn-primary">Take Screenshot</button>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|
26
renderer.js
26
renderer.js
|
@ -1,9 +1,7 @@
|
||||||
const electron = require('electron');
|
const electron = require('electron');
|
||||||
const remote = electron.remote;
|
|
||||||
const desktopCapturer = electron.desktopCapturer;
|
const desktopCapturer = electron.desktopCapturer;
|
||||||
const electronScreen = electron.screen;
|
const electronScreen = electron.screen;
|
||||||
const shell = electron.shell;
|
const shell = electron.shell;
|
||||||
const dialog = remote.dialog;
|
|
||||||
|
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const os = require('os');
|
const os = require('os');
|
||||||
|
@ -11,22 +9,9 @@ const path = require('path');
|
||||||
|
|
||||||
const screenshot = document.getElementById('screen-shot');
|
const screenshot = document.getElementById('screen-shot');
|
||||||
const screenshotMsg = document.getElementById('screenshot-path');
|
const screenshotMsg = document.getElementById('screenshot-path');
|
||||||
const pathButton = document.getElementById('path-button');
|
|
||||||
|
|
||||||
var screenshotPath = '';
|
|
||||||
|
|
||||||
pathButton.addEventListener('click', function(event) {
|
|
||||||
dialog.showSaveDialog(function(fileName) {
|
|
||||||
if (fileName === undefined) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
screenshotPath = fileName;
|
|
||||||
screenshotMsg.textContent = screenshotPath;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
screenshot.addEventListener('click', function(event) {
|
screenshot.addEventListener('click', function(event) {
|
||||||
screenshotMsg.textContent = "Gathering screenshot...";
|
screenshotMsg.textContent = 'Gathering screenshot...';
|
||||||
const thumbSize = determineScreenShot();
|
const thumbSize = determineScreenShot();
|
||||||
let options = { types: ['screen'], thumbnailSize: thumbSize };
|
let options = { types: ['screen'], thumbnailSize: thumbSize };
|
||||||
|
|
||||||
|
@ -35,13 +20,10 @@ screenshot.addEventListener('click', function(event) {
|
||||||
|
|
||||||
sources.forEach(function(source) {
|
sources.forEach(function(source) {
|
||||||
if (source.name === 'Entire Screen' || source.name === 'Screen 1') {
|
if (source.name === 'Entire Screen' || source.name === 'Screen 1') {
|
||||||
|
const screenshotPath = path.join(os.tmpdir(), 'screenshot.png');
|
||||||
|
|
||||||
if (screenshotPath === '') {
|
fs.writeFile(screenshotPath, source.thumbnail.toPng(), function(err) {
|
||||||
screenshotPath = path.join(os.tmpdir(), 'screenshot.png');
|
if (err) return console.log(err.message);
|
||||||
}
|
|
||||||
|
|
||||||
fs.writeFile(screenshotPath, source.thumbnail.toPng(), function(error) {
|
|
||||||
if (error) return console.log(error.message);
|
|
||||||
|
|
||||||
shell.openExternal('file://' + screenshotPath);
|
shell.openExternal('file://' + screenshotPath);
|
||||||
var message = 'Saved screenshot to: ' + screenshotPath;
|
var message = 'Saved screenshot to: ' + screenshotPath;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user