在我的脚本初始化中,我必须阅读屏幕的分辨率,以便我知道如何调整浏览器的窗口大小。
有什么想法吗?
提前致谢!
答案 0 :(得分:2)
这里有一些代码可以获得主监视器或所有多个监视器的分辨率。 此外,最后一个函数返回一个布尔值,表示您是否有多个监视器。
'*******************************************************************
'TotalScreenWidth & TotalScreenHeight
'by Michael Innes
'October 2012
'Intended for getting the total resolution when you have multiple monitors
'Returns the width and the height (respectively) across all the screens.
Function TotalScreenWidth()
TotalScreenWidth = Window("regexpwndtitle:=Program Manager").GetROProperty("width")
End Function
Function TotalScreenHeight()
TotalScreenHeight = Window("regexpwndtitle:=Program Manager").GetROProperty("height")
End Function
'*******************************************************************
'ScreenWidth & ScreenHeight
'by Michael Innes
'October 2012
'Retrieves the width and height (respectively) of the primary screen (the screen that the taskbar is on)
'This only works if the taskbar is at the bottom of the screen
Function ScreenWidth()
ScreenWidth = Window("object class:=Shell_TrayWnd").GetROProperty("width")
End Function
Function ScreenHeight()
ScreenHeight = Window("object class:=Shell_TrayWnd").GetROProperty("height") + Window("object class:=Shell_TrayWnd").GetROProperty("y")
End Function
'*******************************************************************
'MultipleMonitors
'by Michael Innes
'October 2012
'Returns a boolean that determines if the computer has multiple monitors attached.
'This only works if the taskbar is at the bottom of the left-most screen.
'If the taskbar is on the right-most monitor, this function will incorrectly report the multiple monitors as being False.
Function MultipleMonitors()
MultipleMonitors = Eval((screenWidth <> TotalScreenWidth) OR (screenHeight <> TotalScreenHeight))
End Function
答案 1 :(得分:1)
这实际上非常简单,找到桌面窗口并获取其尺寸。
width = Window("text:=Program Manager").GetROProperty("width")
height = Window("text:=Program Manager").GetROProperty("height")
Print width & ", " & height
这适用于单个显示器,我没有检查当你有多个显示器时会发生什么。