Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moving the mouse on Secondary Display when an Additional Monitor is connected #508

Open
SibaPrasadTech opened this issue May 2, 2023 · 2 comments

Comments

@SibaPrasadTech
Copy link

Short summary
Hi,
I am creating a Remote-Access feature for my chat app. Everything works as expected. But for moving the mouse on the Secondary display I am unable to find any API in nutjs documentation. If I have connected a secondary display, then the mouse.move() only works on the primary screen. Need to know whether this is supported or not? If not, then where can I get started to make mouse.move accept a screenId input so that we can move the mouse in the secondary display as well.

@SibaPrasadTech SibaPrasadTech changed the title Moving the mouse on Second screen when an Additional Monitor is connected Moving the mouse on Secondary Display when an Additional Monitor is connected May 2, 2023
@s1hofmann
Copy link
Member

s1hofmann commented May 3, 2023

Hi @SibaPrasadTech 👋

Need to know whether this is supported or not?

It’s currently not supported.

If not, then where can I get started to make mouse.move accept a screenId input so that we can move the mouse in the secondary display as well

I don’t think this additional parameter is needed.
You can pass whatever coordinates you want to mouse.move, but you’d have to make sure the underlying provider is able to handle it.

@adamjerickson
Copy link

I'm doing a similar thing. You will want to offset your coordinates by the share'd display's bounds.x and bounds.y values.

As far as the mouse is concerned all the screens are one big canvas and the x and y go across all of them. Primary monitor upper left corner is always 0, 0. All other monitors are relative to that. So, if the primary monitor is on the left, is 1920px wide, and the second monitor is to the right of that, the first x pixel on the second monitor is 1921px. If the second monitor was on the left the rightmost pixel on that monitor would be a x = -1px.

In my case, I use the screen.getAllDisplays() from Electron and find the display being shared, and look at screen.bounds.x and y and add/subtract to the value being passed in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants