How to use the robotjs.getMousePos 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 zz85 / contact.js / src / touchpad.js View on Github external
updateMouse() {
		// periodically poll the system for mouse coordinates
		// console.log('updateMouse');
		var mouse = robot.getMousePos();
		this.mouse = {
			x: mouse.x,
			y: mouse.y
		};

		this.screenSize = robot.getScreenSize();
	}
github bdell / os-input-capture / src / mouse-logger.js View on Github external
*
        * Adapted from Tim Caswell's nice solution to read a linux joystick
        * http://nodebits.org/linux-joystick
        * https://github.com/nodebits/linux-joystick
        */
        let event = {
            leftBtn: (buffer[0] & 1) > 0, // Bit 0
            rightBtn: (buffer[0] & 2) > 0, // Bit 1
            middleBtn: (buffer[0] & 4) > 0 // Bit 2
        };
        ////// end shared work //////

        if (this.active) {
            if (event.leftBtn || event.rightBtn || event.middleBtn) {
                // TODO: Handle clicking and dragging elegantly
                let { x, y } = robot.getMousePos();
                let { leftBtn, middleBtn, rightBtn } = event;
                let eventData = {
                    timeStamp: Date.now(),
                    x: x,
                    y: y,
                    leftBtn: leftBtn,
                    middleBtn: middleBtn,
                    rightBtn: rightBtn
                };
                this.writeStream.log('info', eventData);
                if (!_.isUndefined(this.parent)) {
                    if (!_.isUndefined(this.parent.getWindow)) {
                        this.parent.getWindow();
                    }
                }
            }
github crowbartools / Firebot / lib / common / handlers / game-controls / joystick.js View on Github external
function joystick(inputEvent) {
    let mousex = inputEvent.input.x;
    let mousey = inputEvent.input.y;
    let mouseSpeed = 50;

    // Get current mouse position
    let mousePos = robot.getMousePos();
    let mousePosX = mousePos.x;
    let mousePosY = mousePos.y;

    // If mousex is negative, move left. Else move right.
    if (mousex < 0) {
        mousePosX = mousePosX - mouseSpeed;
    } else {
        mousePosX = mousePosX + mouseSpeed;
    }
    // If mousey is negative, move up. Else move down.
    if (mousey < 0) {
        mousePosY = mousePosY - mouseSpeed;
    } else {
        mousePosY = mousePosY + mouseSpeed;
    }
github muffinista / before-dawn / src / main / index.js View on Github external
var runScreenSaver = function() {
  var displays = getDisplays();

  var saver = global.savers.getCurrentData();

  // make sure we have something to display
  if ( typeof(saver) === "undefined" ) {
    return;
  }

  saver = global.savers.applyPreload(saver);
  
  oldMousePosition = robot.getMousePos();

  // move cursor so far off screen, it isn't even funny
  robot.moveMouse(30000, 30000);
  
  // @todo maybe add an option to only run on a single display?
  
  // limit to a single screen when debugging
  if ( debugMode === true ) {
    if ( typeof(app.dock) !== "undefined" ) {
      app.dock.show();
    }
  }
  
  try {
    // turn off idle checks for a couple seconds while loading savers
    stateManager.ignoreReset(true);
github crowbartools / Firebot / lib / interactive / game-controls / joystick / joystickProcessor.js View on Github external
function joystick(report) {
    var dbSettings = new JsonDB("./user-settings/settings", true, false);

    // Get mouse speed setting
    try{
        var mouseSpeed = parseInt( dbSettings.getData('/interactive/mouse/mouseSpeed') );
        if(isNaN(mouseSpeed) === true){
            var mouseSpeed = 50;
        }
    }catch(err){
        var mouseSpeed = 50;
    }

    // Move the mouse based on joystick feedback.
    var mouse = rjs.getMousePos();
    var mean = report.coordMean;
    if (!isNaN(mean.x) && !isNaN(mean.y)) {
        rjs.moveMouse(
            Math.round(mouse.x + mouseSpeed * mean.x),
            Math.round(mouse.y + mouseSpeed * mean.y)
        );
    }
}
github gasolin / webbymouse / server.js View on Github external
socket.on('mouse', function(pos) {
    if (pos.pw) {
      if (config.passcode !== pos.pw) {
        return;
      }
    }
    if (pos.cmd == 'move' || pos.cmd == 'scroll' || pos.cmd == 'drag') {
      mouse = robot.getMousePos();
      //console.log("Mouse is at x:" + mouse.x + " y:" + mouse.y);
      newX = mouse.x + pos.x * adjustment;
      newY = mouse.y + pos.y * adjustment;
      //console.log('Offset is x:'+ newX + ' y:' + newY);
      //robot.moveMouseSmooth(newX, newY);
      robot.moveMouse(newX, newY);
      mouse = robot.getMousePos();
      //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;
github vshymanskyy / blynk-library-js / bin / blynk-remote.js View on Github external
v1.on('write', function(param) {
  delta_x = deadZone(parseInt(param[0]));
  delta_y = deadZone(-parseInt(param[1]));
  if ((delta_x != 0 || delta_y != 0) && tmr == 0) {
    var mousePos = robot.getMousePos();
    cur_x = mousePos.x;
    cur_y = mousePos.y;
    tmr = setInterval(function() {
      robot.moveMouse(cur_x += delta_x, cur_y += delta_y);
    }, 30);
  } else if (delta_x == 0 && delta_y == 0 && tmr != 0) {
    clearInterval(tmr);
    tmr = 0;
  }
});
github octalmage / pixelcolor / renderer.js View on Github external
timer = setInterval(() => {
    const mouse = robot.getMousePos();
    hex = robot.getPixelColor(mouse.x, mouse.y).toUpperCase();
    colorElement.textContent = hex;
    document.querySelector('body').style.backgroundColor = `#${hex}`;
  }, 200);
}
github rhansby / leap-gamepad / input.js View on Github external
function mac_moveMouse(dx, dy) {
	var mouse_pos = robot.getMousePos();
	robot.moveMouse(mouse_pos.x + dx, mouse_pos.y + dy);
}
github Jay-Rad / DoXM / DoXM_Remote_Control / Services / RCDeviceSockets.ts View on Github external
this.HubConnection.on("TouchMove", (moveX: number, moveY: number, requesterID: string) => {
            if (RCClient.Mode == "Normal" && ViewOnlyToggle.checked) {
                return;
            }
            var viewer = RCClient.ViewerList.find(x => x.ViewerConnectionID == requesterID);
            if (viewer) {
                var mousePos = Robot.getMousePos();
                Robot.moveMouse(mousePos.x + moveX, mousePos.y + moveY);
            }
        });
        this.HubConnection.on("TouchUp", (requesterID: string) => {