1
0
mirror of https://gitee.com/sui-feng-cb/AzurLaneAutoScript1 synced 2026-03-22 01:19:18 +08:00

Fix: Listening to shortcut only when window is focused

This commit is contained in:
LmeSzinc
2021-10-29 01:03:43 +08:00
parent 4d59f57a68
commit e9e7e338fb

View File

@@ -70,6 +70,7 @@ const createWindow = async () => {
} }
}); });
mainWindow.on('focus', function () {
// Dev tools // Dev tools
globalShortcut.register('Ctrl+Shift+I', function () { globalShortcut.register('Ctrl+Shift+I', function () {
if (mainWindow?.webContents.isDevToolsOpened()) { if (mainWindow?.webContents.isDevToolsOpened()) {
@@ -85,6 +86,10 @@ const createWindow = async () => {
globalShortcut.register('Ctrl+Shift+R', function () { globalShortcut.register('Ctrl+Shift+R', function () {
mainWindow?.reload() mainWindow?.reload()
}); });
});
mainWindow.on('blur', function () {
globalShortcut.unregisterAll()
});
// Minimize, maximize, close window. // Minimize, maximize, close window.
ipcMain.on('window-min', function () { ipcMain.on('window-min', function () {
@@ -103,6 +108,7 @@ const createWindow = async () => {
}); });
}; };
// No DPI scaling // No DPI scaling
app.commandLine.appendSwitch('high-dpi-support', '1'); app.commandLine.appendSwitch('high-dpi-support', '1');
app.commandLine.appendSwitch('force-device-scale-factor', '1'); app.commandLine.appendSwitch('force-device-scale-factor', '1');