Discussion:
How to get usable screen size (maybe WMI?)
(too old to reply)
Hadi
2005-07-18 08:17:01 UTC
Permalink
Hi all,

I am trying to determine the usable screen size of desktop computers. I
found WMI classes that would return the desktop resolution BUT I need:
[screen height] - [taskbar height] = [usable screen size]
Is there a way to determine if the auto-hide is enabled? Can I determine the
height of the taskbar?

I use the "Win32_DesktopMonitor" WMI class at the moment but this only
returns the set screen resolution.

Any idea on how to do this via WMI or maybe read values out of the registry.
I looked into some TechNet articles but I didn't find anything helpful yet.

Regards,
Hadi
mayayana
2005-07-18 13:00:26 UTC
Permalink
It's actually much easier than that. You can use the IE
window screen object:

Dim IE, Scr, s
Set IE = CreateObject("InternetExplorer.Application")
IE.visible = False
IE.Navigate("about:blank")
Do Until IE.ReadyState = 4
Loop

Set Scr = IE.Document.parentWindow.screen

s = "Width: " & Scr.width & vbCrLf
s = s & "Height: " & Scr.height & vbCrLf
s = s & "Available Width: " & Scr.availwidth & vbCrLf
s = s & "Available Height: " & Scr.availheight & vbCrLf
s = s & "Bits Per Pixel: " & Scr.colordepth & vbCrLf

MsgBox s

Set Scr = Nothing
IE.Quit
Set IE = Nothing


--
--
Post by Hadi
Hi all,
I am trying to determine the usable screen size of desktop computers. I
[screen height] - [taskbar height] = [usable screen size]
Is there a way to determine if the auto-hide is enabled? Can I determine the
height of the taskbar?
I use the "Win32_DesktopMonitor" WMI class at the moment but this only
returns the set screen resolution.
Any idea on how to do this via WMI or maybe read values out of the registry.
I looked into some TechNet articles but I didn't find anything helpful yet.
Regards,
Hadi
Hadi
2005-07-18 14:10:11 UTC
Permalink
Hi mayayana,

Thank you for your hint. I would like to use this functionality in a login
script and some of our clients are still running on P2.

I found another solution which does not require to start an instance of IE
during logon:

Set objShell = CreateObject("WScript.Shell")
intBinArray =
objShell.RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Explore
r\StuckRects2\Settings")
If intBinArray(8) / 2 = Int(intBinArray(8) / 2) Then
bAutoHide = False
Else
bAutoHide = True
End If
intTaskBarWidth = intBinArray(20)

This is I think quicker on slower clients - I just query the registry and
substract the width of the taskbar (if it is not in auto-hide mode) from the
screen resolution

Thank you very much for helping me out with your tip!!
Post by mayayana
It's actually much easier than that. You can use the IE
Dim IE, Scr, s
Set IE = CreateObject("InternetExplorer.Application")
IE.visible = False
IE.Navigate("about:blank")
Do Until IE.ReadyState = 4
Loop
Set Scr = IE.Document.parentWindow.screen
s = "Width: " & Scr.width & vbCrLf
s = s & "Height: " & Scr.height & vbCrLf
s = s & "Available Width: " & Scr.availwidth & vbCrLf
s = s & "Available Height: " & Scr.availheight & vbCrLf
s = s & "Bits Per Pixel: " & Scr.colordepth & vbCrLf
MsgBox s
Set Scr = Nothing
IE.Quit
Set IE = Nothing
--
--
Post by Hadi
Hi all,
I am trying to determine the usable screen size of desktop computers. I
[screen height] - [taskbar height] = [usable screen size]
Is there a way to determine if the auto-hide is enabled? Can I determine
the
Post by Hadi
height of the taskbar?
I use the "Win32_DesktopMonitor" WMI class at the moment but this only
returns the set screen resolution.
Any idea on how to do this via WMI or maybe read values out of the
registry.
Post by Hadi
I looked into some TechNet articles but I didn't find anything helpful
yet.
Post by Hadi
Regards,
Hadi
mayayana
2005-07-18 23:38:50 UTC
Permalink
That's interesting. I've never been aware of that
setting before. On my 98SE machine it's StuckRects,
though. There is no StuckRects2 key.

--
--
Post by Hadi
Hi mayayana,
Thank you for your hint. I would like to use this functionality in a login
script and some of our clients are still running on P2.
I found another solution which does not require to start an instance of IE
Set objShell = CreateObject("WScript.Shell")
intBinArray =
objShell.RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Explore
r\StuckRects2\Settings")
If intBinArray(8) / 2 = Int(intBinArray(8) / 2) Then
bAutoHide = False
Else
bAutoHide = True
End If
intTaskBarWidth = intBinArray(20)
This is I think quicker on slower clients - I just query the registry and
substract the width of the taskbar (if it is not in auto-hide mode) from the
screen resolution
Thank you very much for helping me out with your tip!!
Post by mayayana
It's actually much easier than that. You can use the IE
Dim IE, Scr, s
Set IE = CreateObject("InternetExplorer.Application")
IE.visible = False
IE.Navigate("about:blank")
Do Until IE.ReadyState = 4
Loop
Set Scr = IE.Document.parentWindow.screen
s = "Width: " & Scr.width & vbCrLf
s = s & "Height: " & Scr.height & vbCrLf
s = s & "Available Width: " & Scr.availwidth & vbCrLf
s = s & "Available Height: " & Scr.availheight & vbCrLf
s = s & "Bits Per Pixel: " & Scr.colordepth & vbCrLf
MsgBox s
Set Scr = Nothing
IE.Quit
Set IE = Nothing
--
--
Post by Hadi
Hi all,
I am trying to determine the usable screen size of desktop computers. I
[screen height] - [taskbar height] = [usable screen size]
Is there a way to determine if the auto-hide is enabled? Can I determine
the
Post by Hadi
height of the taskbar?
I use the "Win32_DesktopMonitor" WMI class at the moment but this only
returns the set screen resolution.
Any idea on how to do this via WMI or maybe read values out of the
registry.
Post by Hadi
I looked into some TechNet articles but I didn't find anything helpful
yet.
Post by Hadi
Regards,
Hadi
Loading...