How to use the robotjs.keyToggle function in robotjs

To help you get started, we’ve selected a few robotjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github symphonyoss / SymphonyElectron / tests / spectron / minimize-on-close.spectron.js View on Github external
} else {

                    robot.setMouseDelay(100);
                    robot.moveMouseSmooth(200, 10);
                    robot.mouseClick();
                    robot.setKeyboardDelay(100);

                    // Key tap 10 times as "Minimize on Close" is in the
                    // 10th position under view menu item
                    for (let i = 0; i < 10; i++) {
                        robot.keyTap('down');
                    }
                    robot.keyTap('enter');

                    robot.keyToggle('w', 'down', ['command']);
                    robot.keyToggle('w', 'up');
                    robot.keyToggle('command', 'up');
                    app.browserWindow.isMinimized().then(function (minimized) {
                        expect(minimized).toBeTruthy();
                        done();
                    }).catch((err) => {
                        done.fail(new Error(`minimize-on-close failed in isMinimized with error: ${err}`));
                    });
                }
            } else {
                if (!userConfig.minimizeOnClose) {
                    app.browserWindow.getBounds().then((bounds) => {
                        robot.setMouseDelay(100);
                        let x = bounds.x + 95;
                        let y = bounds.y + 35;
                        robot.moveMouse(x, y);
                        robot.mouseClick();
github klayveR / xenontrade / src / modules / poe.js View on Github external
var interval = setInterval(function() {
      // Send chat message if PoE is focused
      if(app.poeFocused && clipboard.readText() === message) {
        clearInterval(interval);
        robot.setKeyboardDelay(0);
        robot.keyToggle("enter", "down");
        robot.keyToggle("enter", "up");
        robot.keyToggle("control", "down");
        robot.keyToggle("v", "down");
        robot.keyToggle("v", "up");
        robot.keyToggle("control", "up");

        if(send) {
          robot.keyToggle("enter", "down");
          robot.keyToggle("enter", "up");
        }

        // Restore clipboard content
        var timeout = setTimeout(function() {
          clipboard.writeText(previousClipboard);
        }, 100);
      }

      // Clear interval if focusing Path of Exile is taking too long
      if(intervalCount >= 500) {
        clearInterval(interval);
        clipboard.writeText(previousClipboard);
      }

      intervalCount++;
github klayveR / xenontrade / src / modules / poe.js View on Github external
var interval = setInterval(function() {
      // Send chat message if PoE is focused
      if(app.poeFocused && clipboard.readText() === message) {
        clearInterval(interval);
        robot.setKeyboardDelay(0);
        robot.keyToggle("enter", "down");
        robot.keyToggle("enter", "up");
        robot.keyToggle("control", "down");
        robot.keyToggle("v", "down");
        robot.keyToggle("v", "up");
        robot.keyToggle("control", "up");

        if(send) {
          robot.keyToggle("enter", "down");
          robot.keyToggle("enter", "up");
        }

        // Restore clipboard content
        var timeout = setTimeout(function() {
          clipboard.writeText(previousClipboard);
        }, 100);
      }

      // Clear interval if focusing Path of Exile is taking too long
      if(intervalCount >= 500) {
        clearInterval(interval);
github symphonyoss / SymphonyElectron / tests / spectron / zoom-in-zoom-out.spectron.js View on Github external
await robot.keyToggle('-', 'up');
            await robot.keyToggle('control', 'up');

            let zoomFactor = await app.electron.webFrame.getZoomFactor()
            await expect(zoomFactor < 1).toBeTruthy();
            await done();
        }
        else {
            let x = 200;
            let y = 200;
            await robot.moveMouse(x, y);
            await robot.mouseClick();
            await robot.keyToggle('0', 'down', ['command']);
            await robot.keyToggle('0', 'up', ['command']);
            for (let i = 0; i < 4; i++) {
                await robot.keyToggle('-', 'down', ['command']);
                await robot.keyToggle('-', 'up', ['command']);
            }
            let zoomFactor = await app.electron.webFrame.getZoomFactor()
            await expect(zoomFactor < 1).toBeTruthy();
            await done();
        }
    });
});
github csiqueirasilva / PoEController / src / game / behaviors / AttackInPlace.js View on Github external
function clearAttackInPlace() {
	ATTACK_IN_PLACE = false;
	robot.keyToggle('shift', 'up');
}
github vshymanskyy / blynk-library-js / bin / blynk-remote.js View on Github external
vpin.on('write', function(param) {
    if (param[0] == 1) {
      robot.keyToggle(key_name, "down");
    } else {
      robot.keyToggle(key_name, "up");
    }
  });
});
github symphonyoss / SymphonyElectron / spec / spectron / spectronWindowsActions.js View on Github external
async pressCtrlM() {
        if (!isMac) {
            await robot.keyToggle('m', 'down', ['control']);
            await robot.keyToggle('m', 'up', ['control']);
        }
        else {
            await robot.keyToggle('m', 'down', ['command']);
            await robot.keyToggle('m', 'up', ['command']);
        }
    }
github jitsi / jitsi-meet-electron / modules / remotecontrol / index.js View on Github external
true);
                break;
            }
            case EVENT_TYPES.mousescroll:{
                //FIXME: implement horizontal scrolling
                if(event.y !== 0) {
                    robot.scrollMouse(
                        Math.abs(event.y),
                        event.y > 0 ? "down" : "up"
                    );
                }
                break;
            }
            case EVENT_TYPES.keydown:
            case EVENT_TYPES.keyup: {
                robot.keyToggle(event.key,
                    KEY_ACTIONS_FROM_EVENT_TYPE[event.type], event.modifiers);
                break;
            }
            case EVENT_TYPES.permissions: {
                if(event.action !== PERMISSIONS_ACTIONS.request)
                    break;

                //Open Dialog and answer
                this.handlePermissionRequest({
                    userId: event.userId,
                    userJID: event.userJID,
                    displayName: event.displayName,
                    screenSharing: event.screenSharing
                });
                break;
            }