// Full screen capture document.getElementById('fullScreenBtn').addEventListener('click', async () => { try { showNotification('Capturing full screen...'); const screenshot = await printScreen.captureFullScreen(); showPreview(screenshot); ScreenshotSaver.saveAsFile(screenshot); showNotification('Screenshot saved!'); } catch (error) { showNotification('Failed to capture screen', 'error'); } });
const copyToClipboard = async () => { if (screenshot) { const blob = await (await fetch(screenshot)).blob(); await navigator.clipboard.write([ new ClipboardItem({ [blob.type]: blob }) ]); alert('Copied to clipboard!'); } }; print screen command
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } } </style> </head> <body> <div class="screenshot-container"> <button class="screenshot-btn" id="fullScreenBtn">📸 Full Screen</button> <button class="screenshot-btn" id="viewportBtn">👁️ Viewport</button> <button class="screenshot-btn" id="elementBtn">🎯 Capture Card</button> </div> // Full screen capture document
const captureFullScreen = async () => { setLoading(true); try { const stream = await navigator.mediaDevices.getDisplayMedia({ video: { mediaSource: "screen" } }); const video = document.createElement('video'); video.srcObject = stream; await video.play(); const canvas = document.createElement('canvas'); canvas.width = video.videoWidth; canvas.height = video.videoHeight; canvas.getContext('2d').drawImage(video, 0, 0); const dataUrl = canvas.toDataURL('image/png'); setScreenshot(dataUrl); stream.getTracks().forEach(track => track.stop()); } catch (error) { console.error('Capture failed:', error); } finally { setLoading(false); } }; async () =>
export default PrintScreenComponent; // Main process (main.js) const { app, BrowserWindow, globalShortcut, clipboard, nativeImage } = require('electron'); const screenshot = require('screenshot-desktop'); app.whenReady().then(() => { // Register global shortcut (Print Screen key) globalShortcut.register('PrintScreen', async () => { try { // Capture screen const imgBuffer = await screenshot();
<!-- Example element to capture --> <div id="captureCard" style="margin: 50px auto; width: 400px; padding: 20px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); border-radius: 16px; color: white; text-align: center;"> <h2>Sample Card</h2> <p>This is a demo card that can be captured!</p> <img src="https://via.placeholder.com/100" alt="Demo" style="border-radius: 50%;"> </div>
const downloadScreenshot = () => { if (screenshot) { const link = document.createElement('a'); link.download = `screenshot_${Date.now()}.png`; link.href = screenshot; link.click(); } };