#Requires AutoHotkey v2.0
#z::
{
ToolTip "Notepad窗口所在显示屏是:" GetMonitor()
}
GetMonitor()
{
CoordMode("Mouse", "Screen")
; MouseGetPos &mx, &my
WinGetPos &mx, &my,,,"ahk_class Notepad"
monitorsCount:=SysGet(80)
Loop monitorsCount
{
; SysGet, monitor, Monitor, %A_Index%
ActualN := MonitorGet(A_Index, &monitorLeft, &monitorTop, &monitorRight, &monitorBottom)
if (monitorLeft <= mx && mx <= monitorRight && monitorTop <= my && my <= monitorBottom){
Return A_Index
}
}
Return 1
}
运行方环境 AutoHotkey V2
验证步骤:1、运行记事本,拖到某个屏幕上。
2、按热键:win+z,查看Tooltip输出情况。
运行效果: