UNPKG

msteams-node-applescript-shortcuts

Version:
92 lines (90 loc) 2.58 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.MeetingsAndCalls = void 0; const applescript_1 = __importDefault(require("applescript")); /** * Microsoft Teams Shortcuts * * https://support.office.com/en-us/article/keyboard-shortcuts-for-microsoft-teams-2e8e2a70-e8d8-4a19-949b-4c36dd5292d2#bkmk_mac_calling */ class MeetingsAndCalls { /** * Accept the incoming video call */ static async accept(reactivate = false) { try { return await this.runScript(`keystroke "a" using {shift down, command down}`, reactivate); } catch (e) { throw e; } } /** * Tell MS Teams to mute */ static async decline(reactivate = false) { try { return await this.runScript(`keystroke "d" using {shift down, command down}`, reactivate); } catch (e) { throw e; } } /** * Tell MS Teams to mute */ static async mute(reactivate = false) { try { return await this.runScript(`keystroke "m" using {shift down, command down}`, reactivate); } catch (e) { throw e; } } /** * Tell MS Teams to turn camera on or off */ static async camera(reactivate = false) { try { return await this.runScript(`keystroke "o" using {shift down, command down}`, reactivate); } catch (e) { throw e; } } /** * Run the Apple script * @param keystroke */ static runScript(keystroke, reactivate = false) { return new Promise((resolve, reject) => { const script = ` ${reactivate ? "set crntAppPath to (path to frontmost application as text)" : ""} tell application "Microsoft Teams" activate tell application "System Events" ${keystroke} end tell end tell ${reactivate ? ` tell application crntAppPath activate end tell ` : ""} `; applescript_1.default.execString(script, (err, rtn) => { if (err) { reject(err); return; } console.log(rtn); resolve('Shortcut executed'); }); }); } } exports.MeetingsAndCalls = MeetingsAndCalls; //# sourceMappingURL=MeetingsAndCalls.js.map