Last active
August 4, 2017 13:48
-
-
Save twolfson/0d374d9d7f26eefe7d38 to your computer and use it in GitHub Desktop.
Screenshot proof of concept for `atom-shell`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
screenshot.png |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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