You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Just found an easy way of screenshotting with mac apps implemented on the JS context - basically by just using the Apple screencapture command line utility.
$('#screenshot').puibutton({
icon: 'fa-sticky-note-o',
click: function(event) {
snapshot();
}
});
async function snapshot() {
var snappo = await new cmd('screenshot', ['-i', '/Users/USER/Desktop/snappo-' + Date.now() + '.png']).execute(); // OK - file in Desktop, spacebar toggle works OK
// var snappo = await new cmd('screenshot', ['-p']).execute(); // OK - file to Desktop (default)
// var snappo = await new cmd('screenshot', ['-R', '0,0,70,300', 'snappo-' + Date.now() + '.png']).execute(); // OK - file in src-tauri
// var snappo = await new cmd('screenshot', ['-R', '0,0,470,200', '/Users/USER/Desktop/snappo-' + Date.now() + '.png']).execute(); // OK - file in Desktop
// var snappo = await new cmd('screenshot', ['-v', '/Users/USER/Desktop/snappo-' + Date.now() + '.mp4']).execute(); // OK - file in Desktop
// var snappo = await new cmd('screenshot', ['-J', 'video', '/Users/USER/Desktop/snappo-' + Date.now() + '.mp4']).execute(); // OK - file in Desktop
// var snappo = await new cmd('screenshot', ['-i', '-U', '/Users/USER/Desktop/snappo-' + Date.now() + '.mp4']).execute(); // OK - .mov file in Desktop, spacebar toggle works OK
}
Note: other args available to the screencapture binary may well work too but the above is enough for me and easy to implement.
For a more cross-platform solution maybe the scap cargo crate would be ideal (https://crates.io/crates/scap) however it would require a little work to be available from the JS side I guess.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Just found an easy way of screenshotting with mac apps implemented on the JS context - basically by just using the Apple screencapture command line utility.
Code:
capabilities .json file -
JS -
// var snappo = await new cmd('screenshot', ['-p']).execute(); // OK - file to Desktop (default)
// var snappo = await new cmd('screenshot', ['-R', '0,0,70,300', 'snappo-' + Date.now() + '.png']).execute(); // OK - file in src-tauri
// var snappo = await new cmd('screenshot', ['-R', '0,0,470,200', '/Users/USER/Desktop/snappo-' + Date.now() + '.png']).execute(); // OK - file in Desktop
// var snappo = await new cmd('screenshot', ['-v', '/Users/USER/Desktop/snappo-' + Date.now() + '.mp4']).execute(); // OK - file in Desktop
// var snappo = await new cmd('screenshot', ['-J', 'video', '/Users/USER/Desktop/snappo-' + Date.now() + '.mp4']).execute(); // OK - file in Desktop
// var snappo = await new cmd('screenshot', ['-i', '-U', '/Users/USER/Desktop/snappo-' + Date.now() + '.mp4']).execute(); // OK - .mov file in Desktop, spacebar toggle works OK
Note: other args available to the screencapture binary may well work too but the above is enough for me and easy to implement.
For a more cross-platform solution maybe the scap cargo crate would be ideal (https://crates.io/crates/scap) however it would require a little work to be available from the JS side I guess.
Beta Was this translation helpful? Give feedback.
All reactions