Skip to content

Instantly share code, notes, and snippets.

@twolfson
Last active August 4, 2017 13:48
Show Gist options
  • Save twolfson/0d374d9d7f26eefe7d38 to your computer and use it in GitHub Desktop.
Save twolfson/0d374d9d7f26eefe7d38 to your computer and use it in GitHub Desktop.
Screenshot proof of concept for `atom-shell`
screenshot.png
// Load in dependencies
var app = require('app');
var fs = require('fs');
var BrowserWindow = require('browser-window');
// When the app is ready
app.on('ready', function onready () {
// Open our browser in an invisible window
var win = new BrowserWindow({
width: 800,
height: 600,
show: false
});
win.loadUrl('http://google.com/');
win.show();
// When it loads, screenshot it
win.webContents.on('did-finish-load', function() {
win.capturePage(function handleCapture (img) {
console.log(img);
fs.writeFileSync('screenshot.png', img);
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment