(mb: Menubar)
| 22 | * @param mb - The menubar instance whose window is captured. |
| 23 | */ |
| 24 | export function takeScreenshot(mb: Menubar) { |
| 25 | const date = new Date(); |
| 26 | const dateStr = date.toISOString().replaceAll(':', '-'); |
| 27 | |
| 28 | const capturedPicFilePath = path.join( |
| 29 | os.homedir(), |
| 30 | `${dateStr}-${APPLICATION.NAME}-screenshot.png`, |
| 31 | ); |
| 32 | |
| 33 | if (!mb.window) { |
| 34 | return; |
| 35 | } |
| 36 | |
| 37 | mb.window.capturePage().then((img) => { |
| 38 | fs.writeFile(capturedPicFilePath, img.toPNG(), () => |
| 39 | logInfo('takeScreenshot', `Screenshot saved ${capturedPicFilePath}`), |
| 40 | ); |
| 41 | }); |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * Open the directory containing the application log file in the OS file manager. |
no test coverage detected