How to use the robotjs.mouseToggle 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 gasolin / webbymouse / server.js View on Github external
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 typie / typie / static / packages / Mouse / index.js View on Github external
getPressesObj(event, type) {
        let k = event.keycode;
        if (this.moveArray.includes(k)) {
            if (k === this.moveArray[0] && type !== this.keys.up) {this.keys.up = type}
            if (k === this.moveArray[1] && type !== this.keys.left) {this.keys.left = type}
            if (k === this.moveArray[2] && type !== this.keys.down) {this.keys.down = type}
            if (k === this.moveArray[3] && type !== this.keys.right) {this.keys.right = type}
            if (k === this.moveArray[4] && type !== this.keys.speed) {this.keys.speed = type}
        } else if (this.actionArray.includes(k)) {
            if (k === this.actionArray[0] && type !== this.keys.click) {
                this.keys.click = type;
                if (type) { // f was clicked
                    robot.mouseToggle('down', 'left');
                } else { // f was released
                    robot.mouseToggle('up', 'left');
                }
            }
            if (k === this.actionArray[1] && type !== this.keys.rightClick) {
                this.keys.rightClick = type;
                if (type) { // f was clicked
                    robot.mouseToggle('down', 'right');
                } else { // f was released
                    robot.mouseToggle('up', 'right');
                }
            }
            //case 38: this.keys.doubleClick = type; break;
        }
    }
github lucent-sea / InstaTech_Client / InstaTech_CP / app / index.js View on Github external
case "MouseDown":
                robot.moveMouse(Math.round(jsonMessage.PointX * totalWidth + offsetX), Math.round(jsonMessage.PointY * totalHeight + offsetY));
                // Modifier down.
                if (jsonMessage.Alt)
                {
                    robot.keyToggle("alt", "down");
                }
                else if (jsonMessage.Ctrl) {
                    robot.keyToggle("control", "down");
                }
                else if (jsonMessage.Shift) {
                    robot.keyToggle("shift", "down");
                }
                // Mouse down.
                if (jsonMessage.Button == "Left") {
                    robot.mouseToggle("down", "left");
                }
                else if (jsonMessage.Button == "Right") {
                    robot.mouseToggle("down", "right");
                }
                // Modifier up.
                if (jsonMessage.Alt) {
                    robot.keyToggle("alt", "up");
                }
                else if (jsonMessage.Ctrl) {
                    robot.keyToggle("control", "up");
                }
                else if (jsonMessage.Shift) {
                    robot.keyToggle("shift", "up");
                }
                break;
            case "MouseUp":
github symphonyoss / SymphonyElectron / spec / 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 zz85 / contact.js / src / touchpad.js View on Github external
// if (sy) {
					// this.scrollYspeed += sy * 2;
					this.scrollYspeed = this.scrollYspeed * 0.9 + sy * 1.5;
				// }

				if (!this.moved && Date.now() - this.down > 250) {
					robot.mouseToggle('down');
				}
				this.moved = true;

				break;
			case 'te':
				this.last = null;
				if (!this.moved) {
					robot.mouseToggle('down');
					robot.mouseToggle('up');
					this.clicked = true;
				}
				this.lastScroll = null;

				break;
			case 'mm':
				if (!this._isScrolling())
					this.move(coords[0], coords[1], coords[2]);
				break;
			case 'tc':
				break;
			case 'sc':
				this.sendScreen();
				break;
			case 'p': // receives ping
				this.sendPack('pp', [ coords[0]]);
github symphonyoss / SymphonyElectron / tests / spectron / spectronWebActions.js View on Github external
async openContextMenu(locator) {
        if (isWindowsOS) {
            let position = await this.getLocation(locator);
            await robot.setMouseDelay(500);
            await robot.moveMouse(position.x + 20, position.y + 5);
            await robot.mouseToggle("down", "right");
            await robot.mouseToggle("up", "right");
        } else {
            await this.mouseOver(locator);
            //right click twice to make it work on MAC
            await this.rightClickIfElementVisible(locator);
            await this.rightClickIfElementVisible(locator);
        }
    }
github vshymanskyy / blynk-library-js / bin / blynk-remote.js View on Github external
v3.on('write', function(param) {
  if (param[0]==1) {
    robot.mouseToggle("down", "right");
  } else {
    robot.mouseToggle("up", "right");
  }
});
github Macmee / OpenMouse / client.js View on Github external
client.on('mu', data => {
  robot.mouseToggle('up');
});
github ProbablePrime / interactive-keyboard / lib / handlers / mouse / robotjs.js View on Github external
leftClick() {
		mouse.checkBounds();
		robot.mouseToggle('down', 'left');
		setTimeout(() => {
			robot.mouseToggle('up', 'left');
		}, 200);
	},
	rightClick() {