octalmage / robotjs

Node.js Desktop Automation.

Home Page:http://robotjs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[multi-monitor] moveMouse wont move to negative position on mac

bradparks opened this issue · comments

Hey... I use getMousePos to get the mouse position, and it returns negative values sometimes (multiple monitors above my laptop monitor).

I then try and use robot.moveMouse(800, -954) for example, and it only moves to 800, 0.

@bradparks The negative mouse coordinates happen in a multi monitor setup. Basically anything left of your primary display may have negative coordinates.
As for the failing moveMouse did you try anything less than -954 ? If you had got (500 , -300) then you can go negative only on the y axis. Also you can only go till the screen max.

If you could provide more details on what you got from moveMousePos , what your arguments for moveMouse and the screen sizes , you can get a better answer.

The issue is that the code doesn't have explicit multi-monitor support, so anything that works is kind of on accident. I don't think this is an issue on Windows, but for Mac I'll need to look into it.

I think this should be made uniform across all platforms. As you said it is still a hack in Windows. Should probably get the monitor sizes before making the mouse move or throw some kind of error. That would be better.

I agree. I guess we'll need to start with adding c functions to get the number of monitors and their sizes.

Would be nice to have this!
Wish I could help.

any update of this?

I messed around with the code enough to get getPixelColor() working on Windows 10 with 2 monitors. However, in the process of doing so, I've discovered that getting multi-monitor support for every feature would be a massive undertaking. Just about everything in the src folder makes the assumption that the user only needs to operate within their primary display. In @octalmage's defense, though, it appears these files were forked from autopy—most of which haven't been updated in ~8 years.

This is the only really big issue I'm having with this library, really wish it was implemented

+1

At the end I worked around this issue like this, after having done brew install cliclick (link)

const { exec } = require('child_process')
exec('cliclick c:.')
commented

This helps ->Does not support multiple monitors #26
I install the robotjs with npm install git+https://git@github.com:Toinane/robotjs.git --save- dev and rebuild for electron. Find it support multi-screen now.
Thanks, @RomanRandom.

The real work was from @jdan as you can see here : https://github.com/Toinane/robotjs/commits?author=jdan from his fork https://github.com/jdan/robotjs
But yes my fork will work too @Louis-7 👍

commented

@Toinane thanks you for clarifying. Also like your color picker, it inspires me to build something for the designer.

@jdan, thanks!

commented

Hi all, i truly love this library. I'm a little late to the conversation, but I ran into mouse movement issue for multiple external displays as well. I need to support it on multiple operating systems. Are we saying this is a limitation that needs to be accepted with RobotJS?

@teaxio Did you find any workarounds for the multi-monitor issue?

@jkeat Did you happen to find any workarounds for the multi-monitor issue?

commented

@jkeat no my friend, I am suck at this point :( I was hoping that the creators/maintainers of RobotJS can add this ability :( If you or @amcneel find anything, please let me know. I will do the same

commented

I have this issue every time I use this library and it's very limiting.
I'd even just take an option to disable errors and to trust me that I'm doing things in bounds, it's only ever for personal projects and I don't need to be told that the coordinates are outside the main screen's area, trust me.