通过AutoHotKey确定光标所在的监视器。监视器底部值是错误的

问题描述 投票:1回答:1

我希望能够确定光标所在的监视器。理想情况下,这将是任何数量/配置的监视器的动态解决方案。

我认为只读取每个监视器的边界并测试光标是否在所述边界内是很简单的。

CoordMode, Mouse, Screen
GetMonitorMouse()
{
    MouseGetPos, x, y

    SysGet, Mon1, Monitor, 1
    SysGet, Mon2, Monitor, 2
    SysGet, Mon3, Monitor, 3

    if(x >= Mon1Left && x <= Mon1Right && y >= Mon1Bottom && y <= Mon1Top)
    {
        TrayTip,,monitor1, 1, 16
        SetTimer, TurnOffTrayTip, 500
    }
    else if(x >= Mon2Left && x <= Mon2Right && y >= Mon2Bottom && y <= Mon2Top)
    {
        TrayTip,,monitor2, 1, 16
        SetTimer, TurnOffTrayTip, 500
    }
    else if(x >= Mon3Left && x <= Mon3Right && y >= Mon3Bottom && y <= Mon3Top)
    {
        TrayTip,,monitor3, 1, 16
        SetTimer, TurnOffTrayTip, 500
    }
    else
    {
        TrayTip,,monitor unknown %x%-%y%, 1, 16
        SetTimer, TurnOffTrayTip, 500
        SplashTextOn, 400, 300, CursorMonitor, monitor unknown %x%-%y% # %Mon1top% ~ %Mon1Bottom% $ %Mon1Left% ~ %Mon1Right% 
    }

 sleep, 3000
 GetMonitorMouse()

}

GetMonitorMouse()

TurnOffTrayTip:
TrayTip
return

但是,我不明白SysGet返回的界限。底部边界似乎是任意的。例如,qazxsw poi是qazxsw poi,而Mon2Bottom是qazxsw poi。

下面的图像显示了我看到的三台显示器的布局。在绿色中,我显示了SysGet返回的边界(顶部,底部,左侧,右侧)。红色表示显示器的实际尺寸。

Mon1Bottom

我不知道如何测试我的光标所在的监视器。有谁知道如何修复我的脚本?我正在使用Windows 10。

windows autohotkey multiple-monitors mouse-cursor
1个回答
4
投票

你的脚本看起来很好。根据以上评论,这里更准确地描述了您的设置。

-8

所以,我认为它只是归结为'为什么显示器2的底线Y-8?'我认为这可能是偶然的。要修复它,我会尝试以下方法:

  1. 在太空中移动监视器3;
  2. 将监视器2向上移动,然后将其直接重新放置在监视器1上方(可能是最初的预期);
  3. 最后,重新定位显示器3,使其上边缘与显示器2的上边缘一致。

现在,就352中的显示器名称而言,它们可能与Windows显示设置中的识别方式相匹配,也可能不匹配。我认为你只需要确定哪个监视器首先进行测试并继续进行。

© www.soinside.com 2019 - 2024. All rights reserved.