简体   繁体   English

在多显示器环境中包装鼠标

[英]Mouse Wrapping in Multi-Monitor Environments

I've done a fair amount of research into this. 我对此进行了大量研究。 There are programs, like Mousinity, which allow for "mouse wrapping". 有些程序(例如Mousinity)允许“鼠标包裹”。 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? 是否可以通过Windows的某种API调用来控制鼠标指针的行为? EDIT: More specifically, how does the API handle multiple monitors? 编辑:更具体地说,API如何处理多个监视器? 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
}

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. 如果您将监视器放置在主监视器的左侧,则该监视器上的x坐标将为负。 If a monitor is above or partially above the primary monitor, they y-coordinates will be negative in that area. 如果监视器在主监视器之上或部分在主监视器之上,则它们的y坐标在该区域为负。

GetSystemMetrics also has constants that refer only to a Multiple Monitor system. GetSystemMetrics还具有仅引用多监视器系统的常量。 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 SM_XVIRTUALSCREEN和SM_YVIRTUALSCREEN标识虚拟屏幕的左上角,SM_CXVIRTUALSCREEN和SM_CYVIRTUALSCREEN是虚拟屏幕的垂直和水平尺寸

For more see here: 有关更多信息,请参见此处:

For your task I think you probably only need to think about the virtual screen coordinates. 对于您的任务,我认为您可能只需要考虑虚拟屏幕坐标。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM