|
|
|||||||
Hi I'm not sure how to query a second monitor with this UDF. Any help here would be appreciated cheers. I see there is a reference to "DesktopMonitor2" but not sure how to use it in this context ? Code: $Bitmap1 = '\\server\netlogon\Kix2EXE\Wall800.bmp' $Bitmap2 = '\\server\netlogon\Kix2EXE\Wall1024.bmp' $Bitmap3 = '\\server\netlogon\Kix2EXE\Wall1280.bmp' FUNCTION DoWall($HKCU) ? "Setting HKCU Wallpaper to " + $HKCU + "..." ? $=WriteValue("HKCU\Control Panel\Desktop","Wallpaper","",REG_SZ) $WallpaperMode = "1" $=WriteValue("HKCU\Control Panel\Desktop","Wallpaper","$HKCU",REG_SZ) $=WriteValue("HKCU\Control Panel\Desktop","WallpaperStyle","2",REG_SZ) $=WriteValue("HKCU\Control Panel\Desktop","TileWallpaper","0",REG_SZ) $=SetWallpaper($HKCU, $WallpaperMode) ENDFUNCTION $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 = "800x600" DoWall ($Bitmap1) case $screenres1 = "1024x768" DoWall ($Bitmap2 ) case $screenres1 = "1280x800" DoWall ($Bitmap3) case 1 ? "No standard screen resolution detected defaulting to none..................................." DoWall ($Bitmap2 ) ; Must be using some other resolution endselect |
||||||||
|
|
|||||||
From a casual glance of your script, If you are actually getting a value for $screenres2, you are not doing anything with it. Change you Select to something like this... Code: select case $screenres1 = "800x600" or $screenres2 = "800x600" DoWall ($Bitmap1) case $screenres1 = "1024x768" or $screenres2 = "1024x768" DoWall ($Bitmap2 ) case $screenres1 = "1280x800" or $screenres2 = "1280x800" DoWall ($Bitmap3) case 1 ? "No standard screen resolution detected defaulting to none..................................." DoWall ($Bitmap2 ) ; Must be using some other resolution endselect I do not see any code for what $HKCU is, and how you are selecting which screen you are actually changing in the DoWall() function. |
||||||||
|
|
|||||||
firstly this is probably the most efficient method: Code: $wmiColl = GetObject("WinMgmts:root/cimv2").ExecQuery("Select * FROM Win32_DesktopMonitor") For Each $wmiObj In $wmiColl if $wmiObj.PNPDeviceID > ' ' $res = CSTR($wmiObj.ScreenWidth) $nul = setwallpaper('\\server\netlogon\Kix2EXE\Wall'+$res+'.bmp',$WallpaperMode) endif Next Second, it will work because: you cannot set a different wallpaper per monitor people can have monitors with different resolutions |
||||||||
|
|
|||||||
Hi Radimus yes that does makes sense using $res to get the width size and applying it to the name of the bitmap is certainly cleaner and faster. But how do you tell this script to use a default wallpaper in the event the wallpaper doesn't exist ? Many thanks I've tried to use a an if statement as below Code: $Bitmap = '\\Server\netlogon\Kix2EXE\Wall' FUNCTION DoWall($HKCU) ? "Setting HKCU Wallpaper to " + $HKCU + "..." ? $=WriteValue("HKCU\Control Panel\Desktop","Wallpaper","",REG_SZ) $WallpaperMode = "1" $=WriteValue("HKCU\Control Panel\Desktop","Wallpaper","$HKCU",REG_SZ) $=WriteValue("HKCU\Control Panel\Desktop","WallpaperStyle","2",REG_SZ) $=WriteValue("HKCU\Control Panel\Desktop","TileWallpaper","0",REG_SZ) $=SetWallpaper($HKCU, $WallpaperMode) ENDFUNCTION $wmiColl = GetObject("WinMgmts:root/cimv2").ExecQuery("Select * FROM Win32_DesktopMonitor") For Each $wmiObj In $wmiColl $res = CSTR($wmiObj.ScreenWidth) DoWall('$BitMap'+$res+'.bmp') Next e.g I've tried the following but cannot capture the value of $res at this point Code: $wmiColl = GetObject("WinMgmts:root/cimv2").ExecQuery("Select * FROM Win32_DesktopMonitor") if not exits ('$BitMap'+$res+'.bmp') DoWall($BitMap"Default.bmp") Else For Each $wmiObj In $wmiColl $res = CSTR($wmiObj.ScreenWidth) DoWall('$BitMap'+$res+'.bmp') Next Endif |
||||||||
|
|
|||||||
Please use the code tags when posting code in future posts. I added them for you this time. |
||||||||
|
|
|||||||
Hi many thanks to all particuarly Radimus. The solution that works for me is as follows. Apologies Mart, if this code is not in the code tag area,I can't see any option to choose this with a response $wmiColl = GetObject("WinMgmts:root/cimv2").ExecQuery("Select * FROM Win32_DesktopMonitor") For Each $wmiObj In $wmiColl if $wmiObj.PNPDeviceID > ' ' $res = CSTR($wmiObj.ScreenWidth) DoWall($Bitmap1) Endif $res = CSTR($wmiObj.ScreenWidth) if exist('$BitMap'+$res+'.bmp') DoWall('$BitMap'+$res+'.bmp') Else DoWall($Bitmap1) Endif Next |
||||||||
|
|
|||||||
Choose the "reply" link from the bottom of the posting instead of using the "Quick Reply" window. That will provide the formatting menu. The Quick Reply window assumes you're familiar with entering UBB tags manually. You can simply type "[ code ]" at the start of your script and "[ /code ]" at the end, but without the spaces. Edit your post your self and add the code tags so you see what we mean. Once you know how, it's easy. Google "UBB Tags" to see what they are - similar to HTML, but used in these types of BBS systems so the message format is differentiated from HTML. Glenn |