Powertoys: Adjust mouse location after crossing monitor boundry

Created on 6 Feb 2020  路  11Comments  路  Source: microsoft/PowerToys

https://www.reddit.com/r/Windows10/comments/ez4xpz/lets_fix_this_monitor_positioning_issue_after/

Reddit's user vanarebane had a great idea here. When the mouse crosses a monitor boundary, we extrapolate where the mouse should be mapped to on the next monitor as if they had a 1:1 side by side map.

image is from the Reddit link
image

As someone with exactly the setup the image shows, this would be very nice to have.

Help Wanted Idea-New PowerToy

All 11 comments

I have a weird and related problem. My second monitor has a different PPI (I guess this is the problem), so the behavior is like the last image, (with vertical adjustment) but in reverse and it still doesn't span the entire side of the screen.

This is how it's happening on my setup:
It's weird.

So, if we could actually customize the mapping, that'd be ideal.

I could have sworn this was mentioned in another issue, but I cannot find it.

LittleBigMouse does exactly this type of mapping. I'm using it for a 32" 4k @ 125% and a 24" 1920x1200 @ 100% and it works beautifully.

@generix we can't even look at that past the repository readme since it lacks a license file for littlebigmouse

Sorry, did not notice. I've contacted the author to see if they'll consider dealing with the license issue.
@crutkas, if I hear back, would you be the most appropriate to direct them to for questions?

@enricogior , @crutkas, @jkexbx

It should be noted that I contacted the author of LBM back in April and did not hear back. I meant to update this, but forgot due to other projects.

Since the code cannot be viewed due to licensing, I assume this may need to be handled in-house if considered a worthy feature.

@generix
correct, we cannot use code that is not licensed under the MIT license.
But we welcome contribution from the community to implement this feature since it's definitely worthy.

@crutkas
Is anyone working on this? I would be interested in at least looking into doing this.

Could something like GlobalMouseKeyHook (MIT License) be used or would it be better to use Cursor.Position and other built in functions directly?

How would the cursor be tracked in order to sense a monitor transition? Checking for a transition every time the mouse moves seems inefficient (Particularly for mice with high polling rates), but I can't think of another way unless there is a built in function.

I can think of a crude psuedo code version using Screen.DeviceName.

Essentially,

If mouseMovement
          if windowTransition
                   //Function to map 2 linear functions to each other (the window borders)   
                   newYPosition = scaleFactor * oldYPosition + constantYValue

The powertoy would just do
Option 1:
An exact edge to edge map (original reddit image above) where scaleFactor and constantYValue are just calculated behind the scenes.
Pro: Simpler to configure as user, simpler to code
Con: Limiting

Option 2:
Or have the scaleFactor and constantYValue be editable (perhaps with a drop down of nominal values to achieve Option 1 and then a "custom" value)
Pro: More functionality
Con: More complicated to configure, more complicated to code (Although, I think this work would already be necessary for option 1 just without user input)

Might be as simple as do option 1 first then expand into option 2.

As this powertoy wouldn't interact with the other existing powerToys, would it be better to create the functionality separately and then integrate it into PowerToys when it's ready for UI?

No one said they were working on it

Yes it should be coded as a separate exe and then brought into PT. I would also remember about just general monitor placement. Vertical and horizontal and the fact they don't have to be center oriented.

The scale factor I would imagine is based off the monitor and dpi of it as well.

@jmahlers @crutkas
I suggest to implement this in C++ not C#.
It's not completely trivial and it requires to use APIs that are not directly available in C#, so it would need anyway several calls to interop methods, making kind of pointless to write it in C#.
In its first implementation we might accept a basic scenario only, with monitors side by side or one above the other, but in general it should support more complex scenarios like:

image

FYI, LittleBigMouse is licensed as GPL3+. I know it's not MIT, but I did want to make sure everyone was clear on the licensing situation.

LittleBigMouse.Daemon
Copyright (c) 2017 Mathieu GRENET. All right reserved.
This file is part of LittleBigMouse.Daemon.
LittleBigMouse.Daemon is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
LittleBigMouse.Daemon is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with MouseControl. If not, see http://www.gnu.org/licenses/.
mailto:[email protected]
http://www.mgth.fr

Ah, well at least we know.

I've been writing in c++ based on enricogior's advice and the methods in Winuser.h seem sufficient so it's a moot point as LittleBigMouse is c#.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Garconis picture Garconis  路  3Comments

seritools picture seritools  路  3Comments

amorenew picture amorenew  路  3Comments

ivadham picture ivadham  路  3Comments

Satanarious picture Satanarious  路  3Comments