该脚本通过调用 Windows API 确定当前任务栏在屏幕的哪个边缘:左(L)上(T)右(R)下(B)

 

MsgBox % TaskbarEdge()
;返回以下值之一:(左、上、右、下)
;在多显示器设置中,您可以使用WinGetPos或MouseGetPos或SysGet来查找X和Y并将其传递给TaskbarEdge()

; https://www.autohotkey.com/boards/viewtopic.php?f=6&t=81038
TaskbarEdge( X:=0, Y:=0 ) {                         ; by SKAN on D39F/D39F @ tiny.cc/taskbaredge
Local hMonitor:=VarSetCapacity(var,84,0),  v:=NumPut(40,var,"Int")-4
  hMonitor := DllCall("MonitorFromPoint", "Int64",(X & 0xFFFFFFFF) | (Y << 32), "Int",0, "UPtr")
  DllCall("GetMonitorInfo", "Ptr",hMonitor, "Ptr",v)
  DllCall("GetWindowRect", "Ptr",WinExist("ahk_class Shell_SecondaryTrayWnd"), "Ptr",v+68)
  DllCall("SubtractRect", "Ptr",v+52, "Ptr",v+4, "Ptr",v+68)
  DllCall("GetWindowRect", "Ptr",WinExist("ahk_class Shell_TrayWnd"), "Ptr",v+36)
  DllCall("SubtractRect", "Ptr",v+20, "Ptr",v+52, "Ptr",v+36)
Return NumGet(v+12,"Int")>NumGet(v+28,"Int") ? "R" : NumGet(v+16,"Int")>NumGet(v+32,"Int") ? "B"
  : NumGet(v+20,"Int")>NumGet(v+4,"Int") ? "L" : NumGet(v+24,"Int")>NumGet(v+8,"Int") ? "T" : ""
}

 

声明:站内资源为整理优化好的代码上传分享与学习研究,如果是开源代码基本都会标明出处,方便大家扩展学习路径。请不要恶意搬运,破坏站长辛苦整理维护的劳动成果。本站为爱好者分享站点,所有内容不作为商业行为。如若本站上传内容侵犯了原著者的合法权益,请联系我们进行删除下架。