This commit is contained in:
tangtaoit 2024-04-22 17:47:50 +08:00
commit e99c00df8f
2 changed files with 16 additions and 8 deletions

View File

@ -251,13 +251,6 @@ function regShortcut() {
); );
screenshots.startCapture(); screenshots.startCapture();
}); });
globalShortcut.register("esc", () => {
if (screenshots.$win?.isFocused()) {
screenshots.endCapture();
}
});
// 打开所有窗口控制台 // 打开所有窗口控制台
globalShortcut.register("ctrl+shift+i", () => { globalShortcut.register("ctrl+shift+i", () => {
let windows = BrowserWindow.getAllWindows(); let windows = BrowserWindow.getAllWindows();
@ -383,6 +376,21 @@ app.on("ready", () => {
} }
}; };
// 截图添加快捷键esc
screenshots.on('windowCreated', ($win) => {
$win.on('focus', () => {
globalShortcut.register('esc', () => {
if ($win?.isFocused()) {
screenshots.endCapture();
}
});
});
$win.on('blur', () => {
globalShortcut.unregister('esc');
});
});
// 点击确定按钮回调事件 // 点击确定按钮回调事件
screenshots.on("ok", (e, buffer, bounds) => { screenshots.on("ok", (e, buffer, bounds) => {
let filename = tmp.tmpNameSync() + '.png'; let filename = tmp.tmpNameSync() + '.png';

View File

@ -242,4 +242,4 @@ export class UserInfoVM extends ProviderListener {
this.notifyListener(); this.notifyListener();
} }
} }
} }