Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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');
}
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');
}
//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);
});
module.exports = function createEvents (data) {
if (data.click) {
var x = scale(data.clientX, 0, data.canvasWidth, 0, screen.width)
var y = scale(data.clientY, 0, data.canvasHeight, 0, screen.height)
var pos = robot.getMousePos() // hosts current x/y
robot.moveMouse(x, y) // move to remotes pos
robot.mouseClick() // click on remote click spot
robot.moveMouse(pos.x, pos.y) // go back to hosts position
}
if (data.keyCode) {
var k = vkey[data.keyCode].toLowerCase()
if (k === '') k = ' '
var modifiers = []
if (data.shift) modifiers.push('shift')
if (data.control) modifiers.push('control')
if (data.alt) modifiers.push('alt')
if (data.meta) modifiers.push('command')
if (k[0] !== '<') {
console.log('typed ' + k + ' ' + JSON.stringify(modifiers))
if (modifiers[0]) robot.keyTap(k, modifiers[0])
else robot.keyTap(k)
} else {
var screenWidth = width;
var screenHeight = height;
var mean = report.coordMean;
var clicks = report.clicks;
// Move the mouse if we get some info.
if (!isNaN(mean.x) && !isNaN(mean.y)) {
rjs.moveMouse(
Math.round(screenWidth * mean.x),
Math.round(screenHeight * mean.y)
);
}
// Click if someone clicked and clicks are enabled in settings.
if(!isNaN(clicks) && clicks > 0 && mouseClick == "enabled"){
rjs.mouseClick();
}
}
await this.app.browserWindow.getBounds().then(async (bounds) => {
await robot.setMouseDelay(50);
let x = bounds.x + 95;
let y = bounds.y + 200;
await robot.moveMouseSmooth(x, y);
await robot.moveMouse(x, y);
await robot.mouseClick('right');
await robot.setKeyboardDelay(2000);
await robot.keyTap('right');
await robot.keyTap('down');
await robot.keyTap('enter');
}).catch((err1) => {
console.log("Message:" + err1);
async actionForMenusOnMac(arrMenu) {
let webAction = await new WebActions(this.app);
await robot.setMouseDelay(2000);
let x = 5;
let y = 5;
await robot.moveMouseSmooth(x, y);
await robot.moveMouse(x, y);
await robot.mouseClick();
await robot.setKeyboardDelay(100);
for (var i = 0; i < arrMenu.length; i++) {
if (i == 0) {
for (var s = 0; s < arrMenu[i].step; s++) {
await robot.keyTap('right');
}
}
else {
for (var s = 0; s <= arrMenu[i].step; s++) {
await robot.keyTap('down');
}
}
if (arrMenu.length > 1 && i != arrMenu.length - 1) {
//handle right keygen
robot.moveMouse(destX, destY);
}
break;
}
case EVENTS.mousedown:
case EVENTS.mouseup: {
this._mouseButtonStatus
= MOUSE_ACTIONS_FROM_EVENT_TYPE[data.type];
robot.mouseToggle(
this._mouseButtonStatus,
(data.button
? MOUSE_BUTTONS[data.button] : undefined));
break;
}
case EVENTS.mousedblclick: {
robot.mouseClick(
(data.button
? MOUSE_BUTTONS[data.button] : undefined),
true);
break;
}
case EVENTS.mousescroll:{
const { x, y } = data;
if(x !== 0 || y !== 0) {
robot.scrollMouse(x, y);
}
break;
}
case EVENTS.keydown:
case EVENTS.keyup: {
robot.keyToggle(
data.key,
setTimeout(function () {
robot.mouseClick("left");
setTimeout(function () {
SetBagAreaPosition(Inventory.getIndex());
}, 24);
}, 24);
};