How to use the robotjs.dragMouse 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 / 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 zz85 / contact.js / src / touchpad.js View on Github external
var vx = dx * speed;
		var vy = dy * speed;
		var tx = mouse.x + vx;
		var ty = mouse.y + vy;

		this.speed = speed;


		this.mouse.x = tx;
		this.mouse.y = ty;
		// ideally we shouldn't clamp - and let the os handle it.
		this.mouse.x = Math.min(Math.max(0, tx), this.screenSize.width);
		this.mouse.y = Math.min(Math.max(0, ty), this.screenSize.height);

		if (this.forceDown) {
			robot.dragMouse(this.mouse.x, this.mouse.y);
		}
		else robot.moveMouse(this.mouse.x, this.mouse.y);
		// console.log('currentSpeed', currentSpeed, '->', speed);
		// console.log('vx', vx, vy);
		// console.log('move', tx, ty);
	}
github symphonyoss / SymphonyElectron / spec / 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 jitsi / jitsi-meet-electron-utils / remotecontrol / index.js View on Github external
const { id, data } = message;

        // If we haven't set the display prop. We haven't received the remote
        // control start message or there was an error associating a display.
        if(!this._display
            && data.type != REQUESTS.start) {
            return;
        }
        switch(data.type) {
            case EVENTS.mousemove: {
                const { width, height, x, y } = this._display.bounds;
                const scaleFactor = this._getDisplayScaleFactor();
                const destX = data.x * width * scaleFactor + x;
                const destY = data.y * height * scaleFactor + y;
                if(this._mouseButtonStatus === "down") {
                    robot.dragMouse(destX, destY);
                } else {
                    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: {
github codedbyandrew / draw-anywhere / app / main.js View on Github external
2: jsonData.data[2] / 4095,
                            3: jsonData.data[3] / 4095,
                            4: jsonData.data[4] / 4095,
                            5: jsonData.data[5] / 4095,
                            6: jsonData.data[6] / 4095,
                            7: jsonData.data[7] / 4095
                        });
                        var x = Math.round(output.x * (calibratorScreenWidth - 1));
                        var y = Math.round(output.y * (calibratorScreenHeight - 1));
                        console.log(screenTopCornerX + x, screenTopCornerY + y, output.onScreen);
                        if (output.onScreen > .8) {
                            if (!mouseDown) {
                                robot.mouseToggle("down");
                                mouseDown = true;
                            }
                            robot.dragMouse(screenTopCornerX + x, screenTopCornerY + y);
                        } else {
                            if (mouseDown) {
                                robot.mouseToggle("up");
                                mouseDown = false;
                            }
                        }
                    }
                    if (time == undefined) {
                        time = Date.now();
                    }
                    jsonData.rate = Date.now() - time;
                    jsonData.time = (Date.now() - initTime) / 1000;
                    time = Date.now();
                    if (paused) {
                        sendDataToCanvas();
                    }
github jitsi / jitsi-meet-electron / modules / remotecontrol / index.js View on Github external
onRemoteControlEvent(event) {
        if(!this.started && event.type !== EVENT_TYPES.permissions) {
            return;
        }
        switch(event.type) {
            case EVENT_TYPES.mousemove: {
                const x = event.x * width, y = event.y * height;
                if(mouseButtonStatus === "down") {
                    robot.dragMouse(x, y);
                } else {
                    robot.moveMouse(x, y);
                }
                break;
            }
            case EVENT_TYPES.mousedown:
            case EVENT_TYPES.mouseup: {
                mouseButtonStatus = MOUSE_ACTIONS_FROM_EVENT_TYPE[event.type];
                robot.mouseToggle(
                    mouseButtonStatus,
                    (event.button ? MOUSE_BUTTONS[event.button] : undefined));
                break;
            }
            case EVENT_TYPES.mousedblclick: {
                robot.mouseClick(
                    (event.button ? MOUSE_BUTTONS[event.button] : undefined),