Question

I've done a fair amount of research into this. There are programs, like Mousinity, which allow for "mouse wrapping". In case you know it by another term, that's when the mouse pointer will go off one side of the screen and appear on the other side of the screen.

However, all the programs that do this have failed to include one crucial element in their feature list: Multiple-Monitor set-ups. I am weary of downloading a completely alien piece of software only to have it not work with my set-up.

The down and dirty of this question is this:

Is there a way to control the behavior of the mouse pointer via some kind of API call for Windows? EDIT: More specifically, how does the API handle multiple monitors? Where is the origin for the coordinate plane?

While I do understand it will be much more complicated, here's my pseudocode for what I am trying to do:

if (mouse_position == side_of_screen_of_monitor1 && Mouse_is_being_moved off screen)
{    
    mouse_position == opposite_side_of_screen_of_monitor2
}
Was it helpful?

Solution

The origin is the top left corner of the primary monitor. If you have placed a monitor to the left of the primary monitor, the x-coordinates on that monitor will be negative. If a monitor is above or partially above the primary monitor, they y-coordinates will be negative in that area.

GetSystemMetrics also has constants that refer only to a Multiple Monitor system. SM_XVIRTUALSCREEN and SM_YVIRTUALSCREEN identify the upper-left corner of the virtual screen, SM_CXVIRTUALSCREEN and SM_CYVIRTUALSCREEN are the vertical and horizontal measurements of the virtual screen

For more see here:

For your task I think you probably only need to think about the virtual screen coordinates.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top