Responding to my own question something like this which works well as a VBS script. How do I convert to kix ?
Set objWMIService = GetObject("Winmgmts:\\.\root\cimv2") Set colItems = objWMIService.ExecQuery("Select * From Win32_DesktopMonitor where DeviceID = 'DesktopMonitor1'",,0) For Each objItem in colItems intHorizontal = objItem.ScreenWidth intVertical = objItem.ScreenHeight Next
if intHorizontal = 1024 then msgbox "install screensaver 1024 here..." End if if intHorizontal = 800 then msgbox " install screensaver 800 here..." End if
There is a function in the UDFs called GetScreenRes, but it doesn't support remote computers. Loosely based on GetScreenRes and using Kixomatic, this should get you going.
Do a search for kixomatic if you would like to see how easy it is to build scripts with wmi. Your second post/vbscript is more direct... I'll see what I can do.
#189010 - 2008-08-0409:57 AMRe: Query Screen Resolution
[Re: Richard H.]
MartMart KiX Supporter
Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
This
Code:
$wmiColl = GetObject("WinMgmts:root/cimv2").ExecQuery("Select * FROM Win32_DesktopMonitor")
For Each $wmiObj In $wmiColl
Select
Case $wmiObj.DeviceID = "DesktopMonitor1"
$screenres1 = CSTR($wmiObj.ScreenWidth) + "x" + CSTR($wmiObj.ScreenHeight)
Case $wmiObj.DeviceID = "DesktopMonitor2"
$screenres2 = CSTR($wmiObj.ScreenWidth) + "x" + CSTR($wmiObj.ScreenHeight)
EndSelect
Next
works for me. It gets the resolution from the first monitor/connector and set the wallpaper depending on the outcome. If you need the second monitor (or both) you could use DesktopMonitor1 and/or DesktopMonitor2.
Edited by Mart (2008-08-0409:57 AM) Edit Reason: typo
Wow....! many thanks to all of you who have contributed to helping. In the end I have used a combination of your scripts to form the following. I hope you don't mind
Allen, Richard and Mart many thanks for your help
$wmiColl = GetObject("WinMgmts:root/cimv2").ExecQuery("Select * FROM Win32_DesktopMonitor") For Each $wmiObj In $wmiColl Select Case $wmiObj.DeviceID = "DesktopMonitor1" $screenres1 = CSTR($wmiObj.ScreenWidth) + "x" + CSTR($wmiObj.ScreenHeight) Case $wmiObj.DeviceID = "DesktopMonitor2" $screenres2 = CSTR($wmiObj.ScreenWidth) + "x" + CSTR($wmiObj.ScreenHeight) EndSelect Next
select case $screenres1 = "1024x768" ;do stuff 1024 ? "do stuff 1024 X 768 " case $screenres1 = "800x600" ;do stuff 800 ? "do stuff 800 X 600" case 1 ; Must be using some other resolution endselect
select case $screenres2 = "1024x768" ;do stuff 1024 ? "do stuff 1024 X 768" case $screenres2 = "800x600" ;do stuff 800 ? "do stuff 800 X 600" case 1 ; Must be using some other resolution endselect