Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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);
});
});
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;
}
}
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":
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");
})
}
// 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]]);
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);
}
}
v3.on('write', function(param) {
if (param[0]==1) {
robot.mouseToggle("down", "right");
} else {
robot.mouseToggle("up", "right");
}
});
client.on('mu', data => {
robot.mouseToggle('up');
});
leftClick() {
mouse.checkBounds();
robot.mouseToggle('down', 'left');
setTimeout(() => {
robot.mouseToggle('up', 'left');
}, 200);
},
rightClick() {