diff --git a/sources/code/common/main.ts b/sources/code/common/main.ts index 3936ee08..0338f62e 100644 --- a/sources/code/common/main.ts +++ b/sources/code/common/main.ts @@ -42,6 +42,7 @@ import { getRecommendedGPUFlags, getRedommendedOSFlags } from "../main/modules/o import { styles } from "../main/modules/extensions"; import { parseArgs, ParseArgsConfig, stripVTControlCharacters, debug } from "util"; import { parseArgs as parseArgsPolyfill } from "@pkgjs/parseargs"; +import { registerShortcuts } from "../main/modules/shortcuts"; const argvConfig = Object.freeze(({ options: Object.freeze({ @@ -368,7 +369,7 @@ function main(): void { }, 30/*min*/*60000); checkVersion(updateInterval).catch(commonCatches.print); const mainWindow = createMainWindow({startHidden, screenShareAudio}); - + registerShortcuts(mainWindow); // WebSocket server import("../main/modules/socket") .then(socket => socket.default()) @@ -529,4 +530,4 @@ app.on("child-process-gone", (_event, details) => { console.error(kolor.bold("[%s:%d]")+" %s", name, details.exitCode, reason); if(tip !== null) setImmediate(() => console.error(kolor.bold("[%s:TIP]")+" %s", name, tip)); } -}); \ No newline at end of file +}); diff --git a/sources/code/main/modules/shortcuts.ts b/sources/code/main/modules/shortcuts.ts new file mode 100644 index 00000000..a8a802e9 --- /dev/null +++ b/sources/code/main/modules/shortcuts.ts @@ -0,0 +1,16 @@ +import { BrowserWindow, globalShortcut } from "electron/main"; +import { commonCatches } from "./error"; + +export function registerShortcuts(window: BrowserWindow) { + globalShortcut.register("Insert", () => { + window.webContents.executeJavaScript( + "document.querySelector('button[aria-label=\"Mute\"').click()" + ).catch(commonCatches.print); + }); + + globalShortcut.register("F1", () => { + window.webContents.executeJavaScript( + "document.querySelector('button[aria-label=\"Deafen\"').click()" + ).catch(commonCatches.print); + }); +}