GithubHelp home page GithubHelp logo

Get Screen Dimensions about robotjs HOT 8 CLOSED

octalmage avatar octalmage commented on June 29, 2024
Get Screen Dimensions

from robotjs.

Comments (8)

octalmage avatar octalmage commented on June 29, 2024

I think I'll create a new method for getting the screen size so it's not slowed down by getting the mouse position. The internal C function getMainDisplaySize() does what you want, it will be very easy to expose it to Node.js (with a new name).

I'll try to get this added tonight!

from robotjs.

octalmage avatar octalmage commented on June 29, 2024

Sorry, thought I replied to this. I added getScreenSize:

var robot = require("robotjs");

var screen = robot.getScreenSize();

console.log(screen.width + "x" + screen.height);

I released RobotJS v0.1.2 with this function, update and let me know how it works!

from robotjs.

ThisIsJohnBrown avatar ThisIsJohnBrown commented on June 29, 2024

Perfect! Thank you, @octalmage!

from robotjs.

octalmage avatar octalmage commented on June 29, 2024

from robotjs.

ozkr0124 avatar ozkr0124 commented on June 29, 2024

Good day.

the function to obtain the screen size in macOS does not operate, the result it shows is 0 in width as in height

`var robot = require("robotjs");

// Speed up the mouse.
robot.setMouseDelay(10);

var twoPI = Math.PI * 2.0;
var screenSize = robot.getScreenSize();
console.log(screenSize);
var height = 768;
var width = 1366;

for (var x = 0; x < width; x++) {
y = height * Math.sin((twoPI * x) / width) + height;
robot.moveMouse(x, y);
}`

from robotjs.

data987 avatar data987 commented on June 29, 2024

I've got the same issue! Does somebody know how to solve this?

from robotjs.

selimgr avatar selimgr commented on June 29, 2024

Same issue... any fixes?

from robotjs.

stephanbogner avatar stephanbogner commented on June 29, 2024

If I use NVM to switch to Node v10.23.1 it works. (I use MacOS Catalina 10.15.7)
So apparently there was a change in NodeJS itself that broke robot.getScreenSize() and thus also mouse clicks? 🤔

Note: I didn't investigate at which version it started to break, v10.23.1 was just the one I already had in NVM.

from robotjs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.