How to use robotjs - 10 common examples

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 symphonyoss / SymphonyElectron / tests / spectron / spectronWindowsActions.js View on Github external
async doAlwaysOnTopOnMac() {
        await robot.setMouseDelay(500);
        await robot.moveMouse(190, 0);
        await robot.mouseClick();
        // Key tap 7 times as "Always on Top" is in the
        // 7th position under view menu item
        for (let i = 0; i < 7; i++) {
            await robot.keyTap('down');
        }
        await robot.keyTap('enter');
    }
github symphonyoss / SymphonyElectron / tests / spectron / spectronWindowsActions.js View on Github external
async fullScreenOnMac() {
        await robot.setMouseDelay(100);
        await robot.moveMouseSmooth(205, 10);
        await robot.mouseClick();
        await robot.setKeyboardDelay(100);
        // Key tap 5 times as "Enter Full Screen" is in the
        // 5th position under view menu item
        for (let i = 0; i < 5; i++) {
            await robot.keyTap('down');
        }
        await robot.keyTap('enter');
    }
github symphonyoss / SymphonyElectron / tests / spectron / spectronWindowsActions.js View on Github external
async doAlwaysOnTopOnMac() {
        await robot.setMouseDelay(500);
        await robot.moveMouse(190, 0);
        await robot.mouseClick();
        // Key tap 7 times as "Always on Top" is in the
        // 7th position under view menu item
        for (let i = 0; i < 7; i++) {
            await robot.keyTap('down');
        }
        await robot.keyTap('enter');
    }
github symphonyoss / SymphonyElectron / tests / spectron / spectronWindowsActions.js View on Github external
async fullScreenOnMac() {
        await robot.setMouseDelay(100);
        await robot.moveMouseSmooth(205, 10);
        await robot.mouseClick();
        await robot.setKeyboardDelay(100);
        // Key tap 5 times as "Enter Full Screen" is in the
        // 5th position under view menu item
        for (let i = 0; i < 5; i++) {
            await robot.keyTap('down');
        }
        await robot.keyTap('enter');
    }
github symphonyoss / SymphonyElectron / tests / spectron / spectronWindowsActions.js View on Github external
async fullScreenOnMac() {
        await robot.setMouseDelay(100);
        await robot.moveMouseSmooth(205, 10);
        await robot.mouseClick();
        await robot.setKeyboardDelay(100);
        // Key tap 5 times as "Enter Full Screen" is in the
        // 5th position under view menu item
        for (let i = 0; i < 5; i++) {
            await robot.keyTap('down');
        }
        await robot.keyTap('enter');
    }
github symphonyoss / SymphonyElectron / tests / spectron / spectronWindowsActions.js View on Github external
await this.app.browserWindow.getBounds().then((bounds) => {
            robot.setMouseDelay(500);
            robot.moveMouse(bounds.x + 200, bounds.y + 10);
            robot.mouseToggle("down");
            robot.moveMouse(bounds.x + 205, bounds.y + 10); // Workaround to make this keyword works properly, refer: https://github.com/octalmage/robotjs/issues/389
            robot.dragMouse(x + 205, y + 10);
            robot.mouseToggle("up");
        })
    }
github symphonyoss / SymphonyElectron / tests / spectron / spectronWindowsActions.js View on Github external
await this.app.browserWindow.getBounds().then((bounds) => {
            let x = bounds.x + (bounds.width - width);
            let y = bounds.y + (bounds.height - height);
            robot.setMouseDelay(500);
            // Plus 2 pixels to make sure this function works well on MAC
            robot.moveMouse(bounds.x + 2, bounds.y + 2);
            robot.mouseToggle("down");
            robot.dragMouse(x, y);
            robot.mouseToggle("up");
        })
    }
github gasolin / webbymouse / server.js View on Github external
//console.log("after x:" + mouse.x + " y:" + mouse.y);
    } else if (pos.cmd == 'motion') {
      var x = pos.x;
      var y = pos.y;
      x = (x < 45) ? 45 : x;
      x = (x > 135) ? 135 : x;
      y = (y < 105) ? 105 : y;
      y = (y > 165) ? 165 : y;
      x -= 45;
      y -= 105;
      robot.moveMouse(screenWidth / 90 * x, screenHeight / 60 * y);
    } else if (pos.cmd == 'click') {
      robot.mouseClick();
      // robot.typeString(msg);
    } else if (pos.cmd == 'rightclick') {
      robot.mouseClick('right');
    } else if (pos.cmd == 'scrollstart') {
      robot.mouseToggle('down', 'middle');
    } else if (pos.cmd == 'scrollend') {
      robot.mouseToggle('up', 'middle');
    } else if (pos.cmd == 'dragstart') {
      robot.mouseToggle('down', 'left');
    } else if (pos.cmd == 'dragend') {
      robot.mouseToggle('up', 'left');
    } else if (pos.cmd == 'right') {
      robot.keyTap("right");
    } else if (pos.cmd == 'left') {
      robot.keyTap("left");
    }
    // send to everyone
    //io.emit('mouse', pos);
  });
github ivanseidel / IAMDinosaur / GameManipulator.js View on Github external
GameManipulator.reloadPage = function ()
{
  // retrieves platform
  var platform = process.platform;

  if(/^win/.test(process.platform)) {
    robot.keyTap('r','control');
  } else if(/^darwin/.test(process.platform)) {
    robot.keyTap('r','command');
  }
}