Memory meter (vertical level)
Friday, February 22, 2008 by Richard Mohler | Discussion: DesktopX
Awhile back rabidrobot sent me a memory meter which displays the level horizontally. I want it to display vertical, does anyone know how to change script so it displays vertical instead horizontally? I like it because if you have more than 2 or 3 gb's of memory it works, the stardock plugin one only works with up to 2 gb's. Well here's the script. Maybe someone can help..
'// Multi-Gig Memory Meter
'// Xander 'rabidrobot' Lih Jan 2007
'// http://feebdack.com
'// Please feel free to reuse in any form.
' Set Up Meter Refresher Object
Dim objWMIService, objRefresher, objRefreshItem
Set objWMIService = GetObject("winmgmts:root\cimv2")
Set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set objRefreshItem = objRefresher.AddEnum(objWMIService, "Win32_PerfRawData_PerfOS_Memory").ObjectSet
objRefresher.Refresh
' Important DX-Objects
Dim dxViewbox, dxPercentText
' How often to update the meter in milliseconds.
Const REFRESH_RATE = 1000
' This is good to know - total PC RAM
Dim totalMemory
' Adjust these to fit custom graphics
Const MARG_LEFT = 4 ' Margin to left of zero on meter
Const MAX_WIDTH = 124 ' Total width of bar 100% used
'Called when the script is executed
Sub Object_OnScriptEnter
' I find it handy to nickname some objects - you can easily change these here.
Set dxViewbox = DesktopX.Object("rr_RAM_Viewbox")
Set dxPercentText = DesktopX.Object("rr_RAM_Percent_Text")
' Gather total memory available information
Dim colItems, objItem
Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48)
totalMemory = 0
For Each objItem In colItems
totalMemory = totalMemory + objItem.TotalPhysicalMemory
Next
Set colItems = Nothing
' Start Monitor
Object.SetTimer 111, REFRESH_RATE
End Sub
Sub Object_OnTimer111
' Update information in the refresher object
objRefresher.Refresh
' The refresher is an enumeration, or list
' So we loop through it, even if it might have only one member
Dim availableMemory, objItem, percentUsed
availableMemory = 0
For Each objItem In objRefreshItem
' Gather info - I only get AvailableBytes, but you could
' get any of the info listed in the OnLButtonUp sub too.
availableMemory = availableMemory + objItem.AvailableBytes
Next
percentUsed = (totalMemory - availableMemory) / totalMemory
' Use handy nicknames
dxViewbox.Width = CInt(percentUsed * MAX_WIDTH + MARG_LEFT)
dxPercentText.Text = FormatNumber(percentUsed * 100, 0) & "%"
' Update other text objects you may have, e.g.
' DeaktopX.Object("FreeMemoryText").Text = FormatNumber(availableMemory / 1024^2, 1) & "MB Free"
End Sub
'Called when the script is terminated
Sub Object_OnScriptExit
Set objWMIService = Nothing
Set objRefresher = Nothing
Set dxViewbox = Nothing
Set dxPercentText = Nothing
End Sub
Reply #3 Friday, February 22, 2008 5:40 PM
Reply #4 Friday, February 22, 2008 5:58 PM
Reply #5 Friday, February 22, 2008 10:40 PM
Please login to comment and/or vote for this skin.
Welcome Guest! Please take the time to register with us.
There are many great features available to you once you register, including:
- Richer content, access to many features that are disabled for guests like commenting on the forums and downloading skins.
- Access to a great community, with a massive database of many, many areas of interest.
- Access to contests & subscription offers like exclusive emails.
- It's simple, and FREE!







Reply #1 Friday, February 22, 2008 5:02 PM
- Where you see the word "width" change to Height. (Including variables)
- Where you see the word "left" change to Bottom (If zero is at the bottom)