It is currently September 18th, 2019, 12:12 am

Need help to code a USB Meter - Please

Help with creating, editing & fixing problems with skins
dfghrngsdkg
Posts: 19
Joined: February 16th, 2019, 8:40 pm

Need help to code a USB Meter - Please

dfghrngsdkg » September 6th, 2019, 2:46 pm

Hello World,

I am still new to Rainmeter, Coding and that's why I am reaching out for your expertise on a "Problem" I have with coding.

The Is-Situation:

Right now I am trying to create a "simple" Meter measuring USB-Drives that, once disconnected, disappear altogether from my screen. I tried different codes I found by making them compatible with my design however, as a Newbee-Noob, I failed - due to a lack of comprehension of even Rainmeter-Manuals. By logic I can follow somehow but in practice its not that simple as expected - even so when studying existing codes. So while searching the Forum for solutions (creative input, clues and other codes) I came across this post: https://forum.rainmeter.net/viewtopic.php?f=5&t=18280&hilit=removable+USB

The code looks promising and "simple" (except stuff like the [!SetOptionGroup "Disk1" Y "0R"]) - thingy, so I've put everything I have together and to some extend it works - BUT run into ..things:

Issues:

1. My design to Meter a single Drive consists of different elements. As a such would lengthen the Code, I tried to shorten then (to combine these Elements into a single "StyleBar") - for the purpose to later be able to multiply that StyleBar (SB1, SB2, etc) for each further Drive attached with only the x/y-coordinates left to set.

My approach in theory: I create Styles for each element, to then make them become Meters with plugged in Measures that is reading #Drive1# and so on. I can get it to work, but not without having duplicates of Meters appearing afterwards. I mean the logic behind is somehow clear but I do struggle with its execution.

2. To make Meters, Styles, else appear/disappear the Original Code use the following command: Group=Disk1. I renamed the Command to Croup=Drive1 and when using this command on my Styles, Meters and Measures, it makes them all disappear when disconnecting the Drive BUT! it causes all of these Meters to get ripped from their original position to then end up piled up upon each other. Vice versa (when disabling the Group=Drive1 Command the Meters stay in their designated position, but do not disappear when the Drive is detached.

With this said, I'd like to (bluntly) ask you to help me with finishing this code. Not because I am lazy, but because I sense that I am not far from accomplishing it while struggling to understand certain concepts of coding - even when reading manuals that -in the end gets me minimal clues. In general I am good in visualizing concepts as well as envision things, but coding is still a sort of a kind I am not used to for now. And please forgive me for being unfamiliar with specific terms and due to this might cause confusion.


I'll leave the code here and would be happy if you could clip a bit of your "pleasure time" to help me out.

With kind regards,

Code: Select all

[Rainmeter]
Update=100
;AccurateText=1
Author=jsmorley,ikarus1969, me 
MiddleMouseUpAction=!Refresh
BackgroundMode=2
SolidColor=150,150,150,150
DynamicWindow=1

[Metadata]
Name=e+
Config=
Description=Measures attached USB Drives
Instructions=
Version=1.0
Tags=
License=
Variant=
Preview=

;End of added Metadata


;============ Variables

[Variables]
FONT=avenir lt 65 medium
COLOR=255,255,255
COLORDIAG=255,255,255,190
COLORHDD=255,255,255,160
COLORHDDBG=255,255,255,95
COLORS=255,255,255,170
COLORBACK=255,255,255,95
COLORGRAPH=255,255,255,70


;============ Drive Titles

;Drive1=C: 
Drive1=E:
Drive2=F:
Drive3=G:
Drive4=H:

;============ Styles


[StyleLeft]
FontFace=#FONT#
StringStyle=NORMAL
FontColor=#COLOR#
StringAlign=Left
AntiAlias=1
FontSize=8
SolidColor=0,0,0,1

[StyleCenter]
FontFace=#FONT#
StringStyle=Normal
FontColor=#COLOR#
StringAlign=Center
AntiAlias=1
FontSize=8
SolidColor=0,0,0,1

[StyleCenter_HDD-Value]
FontFace=#FONT#
StringStyle=Normal
FontColor=#COLOR#
StringAlign=Center
AntiAlias=1
FontSize=7
SolidColor=0,0,0,1

[StyleCenter_DiskAccess]
FontFace=#FONT#
StringStyle=Normal
FontColor=#COLOR#
StringAlign=Center
AntiAlias=1
FontSize=7
SolidColor=0,0,0,1

;-------------- Prefix / Postfix for "Transfer"

;[StylePrefix_Transfer]		;<<< How to put the independent "StylePrefix" into the Transfer "Postfix" section? 
FontFace=#FONT#			
StringStyle=NORMAL
FontColor=#COLOR#
StringAlign=Left
AntiAlias=1
FontSize=10
SolidColor=0,0,0,1
Text=[

;[StylePostfix_Transfer]	;<<< How to put the independent "StylePostfix" into the Transfer "Postfix" section? 
FontFace=#FONT#
StringStyle=NORMAL
FontColor=#COLOR#
StringAlign=Left
AntiAlias=1
FontSize=10
SolidColor=0,0,0,1
Text=[


;[StyleTransfer]
;Meter=STRING
;MeterStyle=StyleCenter
;X=88
;Y=5
;Prefix=[
;Postfix=]
;Text="  TRANSFERS  "


;============== Style Elements to combine in a single "Style Bar" are:

;[StyleLabelDrive]
;X=88
;Y=40
;Prefix=[
;Postfix=]
;Text=#Drive1#
;LeftMouseUpAction=!Execute ["#Drive1#"]

;[StyleBar_USED]
;Meter=BAR
;X=37
;Y=54
;W=100
;H=3
;BarOrientation=HORIZONTAL
;BarColor=#COLORS#


;[StyleBar_Free]
;Meter=BAR
;X=37
;Y=54
;W=99
;H=1
;BarOrientation=HORIZONTAL
;Flip=1
;BarColor=#Colorback#

;[StyleBlock]
;Meter=Image
;x=138
;y=53
;w=3
;h=3
;SolidColor=#COLORS#


;[StyleDrivePercentage]
;Meter=STRING
;MeterStyle=StyleLeft
;X=145
;Y=48
;Postfix=%
;Text="%1"
;Percentual=1
;AutoScale=1


;[Style MeterDiskAccess]
;Meter=String
;MeterStyle=StyleCenter_DiskAccess
;StringAlign=Right
;X=-25r
;Y=66
;AutoScale=1
;AntiAlias=1
;Text=%1B/sec


;============ Meter

[MeterStyleTransfer]
Group=Drive1
Meter=STRING
MeterStyle=StyleCenter
X=88
Y=5
Prefix=[
Postfix=]
Text="  TRANSFERS  "

;======

;[MeasureDriveName]	;<<< How to extract (meter/measure) a Drive's given Name if "E" is actual: "Movies" ?



;-------------- Meter of Drive Elements

[MeterLabelDrive1] 
;Group=Drive1
Meter=STRING
;MeasureName=MeasureDriveName
MeterStyle=StyleCenter
X=88
Y=40
Prefix=[
Postfix=]
Text=#Drive1#
LeftMouseUpAction=!Execute ["#Drive1#"]


[DriveMeterBar]
;Group=Drive1
MeasureName=MeasureDrive1_USED
Meter=BAR
X=37
Y=54
W=100
H=3
BarOrientation=HORIZONTAL
BarColor=#COLORS#


[DriveMeterBarInvert]
;Group=Drive1
MeasureName=MeasureDrive1_FREE
Meter=BAR
X=37
Y=54
W=99
H=1
BarOrientation=HORIZONTAL
Flip=1
BarColor=#Colorback#


[DriveBlock]
;Group=Drive1
Meter=Image
x=138
y=53
w=3
h=3
SolidColor=#COLORS#


[MeterDrive1_Percent]
;Group=Drive1
Meter=STRING
MeasureName=MeasureDrive1_FREE
MeterStyle=StyleLeft
X=145
Y=48
Postfix=%
Text="%1"
Percentual=1
AutoScale=1


[MeterDiskAccess]
;Group=Drive1
Meter=String
MeterStyle=StyleCenter_DiskAccess
MeasureName=MeasureDiskAccess
StringAlign=Right
X=-25r
Y=66
AutoScale=1
AntiAlias=1
Text=%1B/sec


;============== Measures (Drive1)


[MeasureDrive1_FREE]
Measure=FreeDiskSpace
;Group=Drive1
Drive=#Drive1#
IgnoreRemovable=0
UpdateDivider=2
Substitute=".0":""


[MeasureDrive1_USED]
Measure=FreeDiskSpace
;Group=Drive1
Drive=#Drive1#
IgnoreRemovable=0
UpdateDivider=2
InvertMeasure=1


[MeasureDrive1_TOTAL]
Measure=FreeDiskSpace
;Group=Drive1
Drive=#Drive1#
Total=1
IgnoreRemovable=0
UpdateDivider=2
Substitute=".0":""
IfCondition=MeasureDrive1_TOTAL = 0
IfTrueAction=[!SetOptionGroup "Drive1" Y "0R"][!HideMeterGroup "Drive1"][!UpdateMeter *][!Redraw]
IfFalseAction=[!SetOptionGroup "Drive1" Y ""][!SetOptionGroup "Drive1" Y ""][!ShowMeterGroup "Drive1"][!UpdateMeter *][!Redraw]
DynamicVariables=1


[MeasureColorBar]
;Group=Drive1
Measure=Calc
Formula=MeasureDrive1_FREE / MeasureDrive1_TOTAL
IfCondition=MeasureColorBar <= 0.1
IfTrueAction= [!SetOption DriveMeterBarInvert BarColor "#COLORRED#"] [!UpdateMeter "DriveMeterBarInvert"][!Redraw]
IfFalseAction=[!SetOption DriveMeterBarInvert BarColor "#COLORBACK#"][!UpdateMeter "DriveMeterBarInvert"][!Redraw]


[MeasureValueDrive1]
Meter=String
MeterStyle=StyleCenter_HDD-Value
MeasureName=MeasureDrive1_FREE
MeasureName2=MeasureDrive1_TOTAL
;Group=Drive1
X=-28r
Y=57
;W=290
;H=14
;Text="%1B | %2B free"
Text="%1B free"
NumOfDecimals=1
AutoScale=1


[MeasureProcessCount]
;Group=Drive1
Measure=Plugin
Plugin=PerfMon
PerfMonObject=System
PerfMonCounter=Processes
PerfMonDifference=0

[MeasureDiskAccess]
;Group=Drive1
Measure=Plugin
Plugin=PerfMon
PerfMonObject=LogicalDisk
PerfMonCounter=Disk Bytes/sec
PerfMonInstance=#Drive1#


;============ Attempt of creating a StyleBar for a Single Drive (e.g. "Drive1") containing all Style Elements
; with the purpose of repetition - depent on the amount of later Drives attached e.g.
; (Drive2 => StyleBar1 /x=5,y=10, Drive3 => StyleBar2 /x=15,y=25, etc.)

;[MeasureBarDrive1]
;Group=Drive1
;Meter=Bar
;MeterStyle1=StyleBar_USED
;MeterStyle2=StyleBar_FREE
;MeterStyle3=StyleDrivePercentage
;MeterStyle4=StyleTransfer
;MeterStlye5=StyleLabelDrive
;MeterStyle6=StyleBlock
;MeterStyle7=MeterDiskAccess
;Group=Drive1
;MeasureName1=MeasureDrive1_USED
;MeasureName2=MeasureDrive1_FREE
;MeasureName3=MeasureDrive1_FREE
;MeasureName4=MeasureProcessCount
;MeasureName5=MeasureDiskAccess
User avatar
CyberTheWorm
Posts: 659
Joined: August 22nd, 2016, 11:32 pm
Location: Surrey, B.C., Canada

Re: Need help to code a USB Meter - Please

CyberTheWorm » September 6th, 2019, 6:10 pm

Code: Select all

[Rainmeter]
Update=1000


[Metadata]
Name=G drive
Author=CyberTheWorm
Information=Displays G drive information | Left click opens drive
Version=1.0.0
License=Creative Commons Attribution - Non - Commercial - Share Alike 3.0

[Variables]
Drive=G:
;-------------- Measures -------------------------

[MeasureDiskLabel]
Measure=FreeDiskSpace
Drive=#Drive#
Label=1
UpdateDivider=5
IgnoreRemovable=0

[MeasureTotalDiskSpace]
Measure=FreeDiskSpace
Drive=#Drive#
Total=1
UpdateDivider=5
IgnoreRemovable=0

[MeasureFreeDiskSpace]
Measure=FreeDiskSpace
Drive=#Drive#
UpdateDivider=5
IgnoreRemovable=0
IfCondition=MeasureFreeDiskSpace = 0
IfTrueAction=[!SetOptionGroup "DiskSkin" Y "0R"] [!SetOptionGroup "Disk" Y "0R"] [!SetOptionGroup "DiskBar" Y "0R"] [!HideMeter "MeterShapeRectangle"] [!HideMeter "MeterDriveInfo"] [!HideMeter "MeterDiskBar"] [!HideMeterGroup "DiskSkin"] [!HideMeterGroup "Disk"] [!HideMeterGroup "DiskBar"] [!UpdateMeter *] [!Redraw]
IfFalseAction=[!SetOptionGroup "DiskSkin" Y "0"] [!SetOptionGroup "Disk" Y "15"] [!SetOptionGroup "DiskBar" Y "80"] [!ShowMeter "MeterShapeRectangle"] [!ShowMeter "MeterDriveInfo"] [!ShowMeter "MeterDiskBar"] [!ShowMeterGroup "DiskSkin"] [!ShowMeterGroup "Disk"] [!ShowMeterGroup "DiskBar"] [!UpdateMeter *] [!Redraw]
DynamicVariables=1

[MeasureUsedDiskSpace]
Measure=FreeDiskSpace
Drive=#Drive#
InvertMeasure=1
UpdateDivider=5
IgnoreRemovable=0
;--------------------  Meters -------------------------

[MeterShapeRectangle]
Meter=Shape
Group=DiskSkin
X=0
Y=0
Shape=Rectangle 3,3,200,100 | Fill Color 32,32,32,255 | StrokeWidth 6 | StrokeColor 0,0,0,220

[MeterDriveInfo]
Meter=String
Group=Disk
X=103
Y=150
MeasureName=MeasureDiskLabel
MeasureName2=MeasureTotalDiskSpace
MeasureName3=MeasureFreeDiskSpace
MeasureName4=MeasureUsedDiskSpace
Text=#Drive#\ %1#CRLF#Total Size: %2B#CRLF#Free: %3B#CRLF#Used: %4B
FontColor=255,255,255,255
StringAlign=Center
AutoScale=1
AntiAlias=1
LeftMouseUpAction=["#Drive#\"]

[MeterDiskBar]
MeasureName=MeasureUsedDiskSpace
Meter=Bar
Group=DiskBar
X=12
Y=80
H=10
W=180
BarColor=0,102,180,255
SolidColor=255,255,255,100
BarOrientation=Horizontal
DynamicVariables=1
I have this for my USB drive, but you could duplicate for other drives
The only source of knowledge is experience. Albert Einstein
Deviant Art Page
dfghrngsdkg
Posts: 19
Joined: February 16th, 2019, 8:40 pm

Re: Need help to code a USB Meter - Please

dfghrngsdkg » September 7th, 2019, 11:59 am

Hello CyberTheWorm,

Thank you for providing me with your Meter. I have taken a look into it and modified (shortened) my file's code. The issue however persists as -different to your design- I have more than one Style-Element that I'd like to combine into a single (flexible) "Style-Bar, so my question isn't answered yet. I also could not make the Meter disappear without to mess its Layout up. Note: "[MeasureColorBar]" is made to notice me when a Drive has 10% storage left by changing its color from Gray to Red.

For a better understanding of what I want to achieve, I made a Graphic of my Meter-Design.

Meter-Design: https://ibb.co/xLjMJ8m
Sorry for having it this way, but whenever I try to add a .jpg I get this Error-Message:

Error
It was not possible to determine the dimensions of the image. Please verify that the URL you entered is correct.


The modified Code I work with is here:

Code: Select all

 [Rainmeter]
Update=100
;AccurateText=1
Author=jsmorley,ikarus1969, me 
MiddleMouseUpAction=!Refresh
BackgroundMode=2
SolidColor=150,150,150,150
DynamicWindow=1

[Metadata]
Name=e+
Config=
Description=Measures attached USB Drives
Instructions=
Version=1.0
Tags=
License=
Variant=
Preview=

;End of added Metadata


;============ Variables

[Variables]
FONT=avenir lt 65 medium
COLOR=255,255,255
COLORDIAG=255,255,255,190
COLORHDD=255,255,255,160
COLORHDDBG=255,255,255,95
COLORS=255,255,255,170
COLORBACK=255,255,255,95
COLORGRAPH=255,255,255,70


;============ Drive Titles

;Drive1=C: 
Drive1=E:
Drive2=F:
Drive3=G:
Drive4=H:

;======== Styles

[StyleLeft]
FontFace=#FONT#
StringStyle=NORMAL
FontColor=#COLOR#
StringAlign=Left
AntiAlias=1
FontSize=8
SolidColor=0,0,0,1

[StyleCenter]
FontFace=#FONT#
StringStyle=Normal
FontColor=#COLOR#
StringAlign=Center
AntiAlias=1
FontSize=8
SolidColor=0,0,0,1

[StyleCenter_HDD-Value]
FontFace=#FONT#
StringStyle=Normal
FontColor=#COLOR#
StringAlign=Center
AntiAlias=1
FontSize=7
SolidColor=0,0,0,1

[StyleCenter_DiskAccess]
FontFace=#FONT#
StringStyle=Normal
FontColor=#COLOR#
StringAlign=Center
AntiAlias=1
FontSize=7
SolidColor=0,0,0,1


;============ Meter

[MeterStyleTransfer]
Group=Drive1
Meter=STRING
MeterStyle=StyleCenter
X=88
Y=5
Prefix=[
Postfix=]
Text="  TRANSFERS  "


;====== Meter


[MeterLabelDrive] 
Meter=STRING
;Group=Drive1
Drive=#Drive1#
;MeasureName=MeasureDriveName
MeterStyle=StyleCenter
X=88
Y=40
Prefix=[
Postfix=]
Text=#Drive1#
LeftMouseUpAction=!Execute ["#Drive1#"]


[DriveMeterBar]
;Group=Drive1
Drive=#Drive1#
MeasureName=MeasureDrive_USED
Meter=BAR
X=37
Y=54
W=100
H=3
BarOrientation=HORIZONTAL
BarColor=#COLORS#


[DriveMeterBarInvert]
;Group=Drive1
MeasureName=MeasureDrive_FREE
Meter=BAR
X=37
Y=54
W=99
H=1
BarOrientation=HORIZONTAL
Flip=1
BarColor=#Colorback#


[DriveBlock]
;Group=Drive1
Drive=#Drive1#
Meter=Image
x=138
y=53
w=3
h=3
SolidColor=#COLORS#


[MeterDrive_Percent]
;Group=Drive1
Meter=STRING
Drive=#Drive1#
MeasureName=MeasureDrive_FREE
MeterStyle=StyleLeft
X=145
Y=48
Postfix=%
Text="%1"
Percentual=1
AutoScale=1


[MeterDiskAccess]
;Group=Drive1
Meter=String
Drive=#Drive1#
MeterStyle=StyleCenter_DiskAccess
MeasureName=MeasureDiskAccess
StringAlign=Right
X=-25r
Y=66
AutoScale=1
AntiAlias=1
Text=%1B/sec

;=========== Measure


[MeasureDrive_FREE]
Measure=FreeDiskSpace
;Group=Drive1
Drive=#Drive1#
IgnoreRemovable=0
UpdateDivider=2
Substitute=".0":""


[MeasureDrive_USED]
Measure=FreeDiskSpace
;Group=Drive1
Drive=#Drive1#
IgnoreRemovable=0
UpdateDivider=2
InvertMeasure=1


[MeasureDrive_TOTAL]
Measure=FreeDiskSpace
;Group=Drive1
Drive=#Drive1#
Total=1
IgnoreRemovable=0
UpdateDivider=2
Substitute=".0":""
IfCondition=MeasureDrive1_TOTAL = 0
IfTrueAction=[!SetOptionGroup "Drive1" Y "0R"][!HideMeterGroup "Drive1"][!UpdateMeter *][!Redraw]
IfFalseAction=[!SetOptionGroup "Drive1" Y ""][!SetOptionGroup "Drive1" Y ""][!ShowMeterGroup "Drive1"][!UpdateMeter *][!Redraw]
DynamicVariables=1


[MeasureColorBar]
Drive=#Drive1#
;Group=Drive1
Measure=Calc
Formula=MeasureDrive_FREE / MeasureDrive_TOTAL
IfCondition=MeasureColorBar <= 0.1
IfTrueAction= [!SetOption DriveMeterBarInvert BarColor "#COLORRED#"] [!UpdateMeter "DriveMeterBarInvert"][!Redraw]
IfFalseAction=[!SetOption DriveMeterBarInvert BarColor "#COLORBACK#"][!UpdateMeter "DriveMeterBarInvert"][!Redraw]


[MeasureValueDrive]
Meter=String
Drive=#Drive1#
MeterStyle=StyleCenter_HDD-Value
MeasureName=MeasureDrive_FREE
MeasureName2=MeasureDrive_TOTAL
;Group=Drive1
X=-28r
Y=57
;W=290
;H=14
;Text="%1B | %2B free"
Text="%1B free"
NumOfDecimals=1
AutoScale=1


[MeasureProcessCount]
;Group=Drive1
Drive=#Drive1#
Measure=Plugin
Plugin=PerfMon
PerfMonObject=System
PerfMonCounter=Processes
PerfMonDifference=0

[MeasureDiskAccess]
;Group=Drive1
Drive=#Drive1#
Measure=Plugin
Plugin=PerfMon
PerfMonObject=LogicalDisk
PerfMonCounter=Disk Bytes/sec
PerfMonInstance=#Drive1#
[code]
User avatar
jsmorley
Developer
Posts: 19457
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Need help to code a USB Meter - Please

jsmorley » September 7th, 2019, 12:26 pm

I'm not entirely clear on what problem you are trying to solve. With a quick look at your code, you have things measuring and being displayed as you want as far as I can see. I'm not clear what "style element" and "style bar" are supposed to represent, and what effect you are looking for.
dfghrngsdkg
Posts: 19
Joined: February 16th, 2019, 8:40 pm

Re: Need help to code a USB Meter - Please

dfghrngsdkg » September 7th, 2019, 2:33 pm

jsmorley wrote:
September 7th, 2019, 12:26 pm
I'm not entirely clear on what problem you are trying to solve. With a quick look at your code, you have things measuring and being displayed as you want as far as I can see. I'm not clear what "style element" and "style bar" are supposed to represent, and what effect you are looking for.
The Meter I made works with a single Drive as intended, all is fine except that the whole Meter won't disappears after disconnecting. It has something to do with "Group=Drive1" and its way to set it right - which I do not understand.

Secondly, I do not understand how to group the various Meter (LabelDrive, DriveMeterBar, DriveMeterBar_Invert, DriveBlock, MeterDrive_Percent, MeterDiskAccess) into a single [StyleBar]?, that contains all of the individual Meter's information (x/y/w/h, etc.) which I can later on easily multiply >> [StyleBar1], [StyleBar2], etc. for each further Drive (F:,G:,etc). Because my problem right now is, that adding a second Drive means I have to duplicate all the said Meters incl. changing their individual positions. With a such [StyleBar] at hand I only need to copy-paste it with changing this copied [Stylebar]'s position (x/y) + the Drive's it shall read from. This would simplify the whole procedure as it would always draw its main layout information of each included Meter from its source.

As a reference of what I am trying to explain please see the linked Image: https://ibb.co/xLjMJ8m


Further, even if there is no need, but I do apologize (again) for my terminology. As a non-coder that is trying to understand how things work by studying, learning all that "gibberish" from scratch I have not better way to explain myself. So please show and have some patience towards unskilled people like me. Vice versa you wouldn't be happy either if I go harsh on you just because you -as a non-medic- would obviously have no access to the medical terminology used because of Latin missing in your vocabulary that would leave you bound to hours of describing "things".

With kind regards,
User avatar
CyberTheWorm
Posts: 659
Joined: August 22nd, 2016, 11:32 pm
Location: Surrey, B.C., Canada

Re: Need help to code a USB Meter - Please

CyberTheWorm » September 7th, 2019, 3:46 pm

Code: Select all

[Rainmeter]
Update=1000

[Metadata]
Author=CyberTheWorm
Version=1.0.0
License=Creative Commons Attribution-Non-Commercial-Share Alike 3.0
Information=Test

[Style]
FontFace=Arial
FontColor=255,255,255,255
FontSize=10
StringEffect=Shadow
FontEffectColor=0,0,0,255
SolidColor=127,127,127,255

;-------------------- Variables ----------------------
[Variables]

;-------------------- Measures ----------------------------
;------------------ C --------------------------------
[MeasureDiskLabelC]
Measure=FreeDiskSpace
Drive=C:
Label=1
UpdateDivider=5

[MeasureTotalDiskSpaceC]
Measure=FreeDiskSpace
Drive=C:
Total=1
UpdateDivider=10

[MeasureFreeDiskSpaceC]
Measure=FreeDiskSpace
Drive=C:
UpdateDivider=10

[MeasureUsedDiskSpaceC]
Measure=FreeDiskSpace
Drive=C:
InvertMeasure=1
UpdateDivider=10

;----------------------- D --------------------------
[MeasureDiskLabelD]
Measure=FreeDiskSpace
Drive=D:
Label=1
UpdateDivider=5
IgnoreRemovable=0

[MeasureTotalDiskSpaceD]
Measure=FreeDiskSpace
Drive=D:
Total=1
UpdateDivider=10
IgnoreRemovable=0

[MeasureFreeDiskSpaceD]
Measure=FreeDiskSpace
Drive=D:
UpdateDivider=10
IgnoreRemovable=0
IgnoreRemovable=0
IfCondition=MeasureFreeDiskSpaceD = 0
IfTrueAction=[!SetOptionGroup "DiskD" Y "0R"] [!SetOptionGroup "DiskBarD" Y "0R"] [!HideMeter "MeterDriveInfoD"] [!HideMeter "MeterUsedDriveBarD"] [!HideMeterGroup "DiskD"] [!HideMeterGroup "DiskBarD"] [!UpdateMeter *] [!Redraw]
IfFalseAction=[!SetOptionGroup "DiskD" Y "10r"] [!SetOptionGroup "DiskBarD" Y "3R"] [!ShowMeter "MeterDriveInfoD"] [!ShowMeter "MeterUsedDriveBarD"] [!ShowMeterGroup "DiskD"] [!ShowMeterGroup "DiskBarD"] [!UpdateMeter *] [!Redraw]
DynamicVariables=1

[MeasureUsedDiskSpaceD]
Measure=FreeDiskSpace
Drive=D:
InvertMeasure=1
UpdateDivider=10
IgnoreRemovable=0

;--------------------------- E ---------------------------
[MeasureDiskLabelE]
Measure=FreeDiskSpace
Drive=E:
Label=1
UpdateDivider=5
IgnoreRemovable=0

[MeasureTotalDiskSpaceE]
Measure=FreeDiskSpace
Drive=E:
Total=1
UpdateDivider=10
IgnoreRemovable=0

[MeasureFreeDiskSpaceE]
Measure=FreeDiskSpace
Drive=E:
UpdateDivider=10
IgnoreRemovable=0
IgnoreRemovable=0
IfCondition=MeasureFreeDiskSpaceE = 0
IfTrueAction=[!SetOptionGroup "DiskE" Y "0R"] [!SetOptionGroup "DiskBarE" Y "0R"] [!HideMeter "MeterDriveInfoE"] [!HideMeter "MeterUsedDriveBarE"] [!HideMeterGroup "DiskE"] [!HideMeterGroup "DiskBarE"] [!UpdateMeter *] [!Redraw]
IfFalseAction=[!SetOptionGroup "DiskE" Y "10r"] [!SetOptionGroup "DiskBarE" Y "3R"] [!ShowMeter "MeterDriveInfoE"] [!ShowMeter "MeterUsedDriveBarE"] [!ShowMeterGroup "DiskE"] [!ShowMeterGroup "DiskBarE"] [!UpdateMeter *] [!Redraw]
DynamicVariables=1

[MeasureUsedDiskSpaceE]
Measure=FreeDiskSpace
Drive=E:
InvertMeasure=1
UpdateDivider=10
IgnoreRemovable=0

;-------------------------- F -----------------------
[MeasureDiskLabelF]
Measure=FreeDiskSpace
Drive=F:
Label=1
UpdateDivider=5
IgnoreRemovable=0

[MeasureTotalDiskSpaceF]
Measure=FreeDiskSpace
Drive=F:
Total=1
UpdateDivider=10
IgnoreRemovable=0

[MeasureFreeDiskSpaceF]
Measure=FreeDiskSpace
Drive=F:
UpdateDivider=10
IgnoreRemovable=0
IgnoreRemovable=0
IfCondition=MeasureFreeDiskSpaceF = 0
IfTrueAction=[!SetOptionGroup "DiskF" Y "0R"] [!SetOptionGroup "DiskBarF" Y "0R"] [!HideMeter "MeterDriveInfoF"] [!HideMeter "MeterUsedDriveBarF"] [!HideMeterGroup "DiskF"] [!HideMeterGroup "DiskBarF"] [!UpdateMeter *] [!Redraw]
IfFalseAction=[!SetOptionGroup "DiskF" Y "10r"] [!SetOptionGroup "DiskBarF" Y "3R"] [!ShowMeter "MeterDriveInfoF"] [!ShowMeter "MeterUsedDriveBarF"] [!ShowMeterGroup "DiskF"] [!ShowMeterGroup "DiskBarF"] [!UpdateMeter *] [!Redraw]
DynamicVariables=1

[MeasureUsedDiskSpaceF]
Measure=FreeDiskSpace
Drive=F:
InvertMeasure=1
UpdateDivider=10
IgnoreRemovable=0

;------------------------------- G ------------------------------
[MeasureDiskLabelG]
Measure=FreeDiskSpace
Drive=G:
Label=1
UpdateDivider=5
IgnoreRemovable=0

[MeasureTotalDiskSpaceG]
Measure=FreeDiskSpace
Drive=G:
Total=1
UpdateDivider=10
IgnoreRemovable=0

[MeasureFreeDiskSpaceG]
Measure=FreeDiskSpace
Drive=G:
UpdateDivider=10
IgnoreRemovable=0
IfCondition=MeasureFreeDiskSpaceG = 0
IfTrueAction=[!SetOptionGroup "DiskG" Y "0R"] [!SetOptionGroup "DiskBarG" Y "0R"] [!HideMeter "MeterDriveInfoG"] [!HideMeter "MeterUsedDriveBarG"] [!HideMeterGroup "DiskG"] [!HideMeterGroup "DiskBarG"] [!UpdateMeter *] [!Redraw]
IfFalseAction=[!SetOptionGroup "DiskG" Y "10r"] [!SetOptionGroup "DiskBarG" Y "3R"] [!ShowMeter "MeterDriveInfoG"] [!ShowMeter "MeterUsedDriveBarG"] [!ShowMeterGroup "DiskG"] [!ShowMeterGroup "DiskBarG"] [!UpdateMeter *] [!Redraw]
DynamicVariables=1

[MeasureUsedDiskSpaceG]
Measure=FreeDiskSpace
Drive=G:
InvertMeasure=1
UpdateDivider=10
IgnoreRemovable=0

;------------------------------------ H ---------------------------------------
[MeasureDiskLabelH]
Measure=FreeDiskSpace
Drive=H:
Label=1
UpdateDivider=5
IgnoreRemovable=0

[MeasureTotalDiskSpaceH]
Measure=FreeDiskSpace
Drive=H:
Total=1
UpdateDivider=10
IgnoreRemovable=0

[MeasureFreeDiskSpaceH]
Measure=FreeDiskSpace
Drive=H:
UpdateDivider=10
IgnoreRemovable=0
IfCondition=MeasureFreeDiskSpaceH = 0
IfTrueAction=[!SetOptionGroup "DiskH" Y "0R"] [!SetOptionGroup "DiskBarH" Y "0R"] [!HideMeter "MeterDriveInfoH"] [!HideMeter "MeterUsedDriveBarH"] [!HideMeterGroup "DiskH"] [!HideMeterGroup "DiskBarH"] [!UpdateMeter *] [!Redraw]
IfFalseAction=[!SetOptionGroup "DiskH" Y "10r"] [!SetOptionGroup "DiskBarH" Y "3R"] [!ShowMeter "MeterDriveInfoH"] [!ShowMeter "MeterUsedDriveBarH"] [!ShowMeterGroup "DiskH"] [!ShowMeterGroup "DiskBarH"] [!UpdateMeter *] [!Redraw]
DynamicVariables=1

[MeasureUsedDiskSpaceH]
Measure=FreeDiskSpace
Drive=H:
InvertMeasure=1
UpdateDivider=10
IgnoreRemovable=0

;--------------------- Meters --------------------------------
;----------------- C ---------------------
[MeterDriveInfoC]
Meter=String
MeterStyle=Style
MeasureName=MeasureDiskLabelC
MeasureName2=MeasureFreeDiskSpaceC
X=151
Y=20r
StringAlign=Center
AntiAlias=1
Percentual=1
Text="C:\ (%1) Free %2%"

[MeterUsedDriveBarC]
MeasureName=MeasureUsedDiskSpaceC
Meter=Bar
BarImage=bar.png
X=61
Y=3R
SolidColor=127,127,127,255
BarOrientation=Horizontal

;------------------- D ------------------
[MeterDriveInfoD]
Meter=String
Group=DiskD
MeterStyle=Style
MeasureName=MeasureDiskLabelD
MeasureName2=MeasureFreeDiskSpaceD
X=151
Y=10r
StringAlign=Center
AntiAlias=1
Percentual=1
Text="D:\ (%1) Free %2%"

[MeterUsedDriveBarD]
MeasureName=MeasureUsedDiskSpaceD
Group=DiskBarD
Meter=Bar
BarImage=bar.png
X=61
Y=3R
SolidColor=127,127,127,255
BarOrientation=Horizontal

;------------------------ E ----------------------
[MeterDriveInfoE]
Meter=String
Group=DiskE
MeterStyle=Style
MeasureName=MeasureDiskLabelE
MeasureName2=MeasureFreeDiskSpaceE
X=151
Y=10r
StringAlign=Center
AntiAlias=1
Percentual=1
Text="E:\ (%1) Free %2%"

[MeterUsedDriveBarE]
MeasureName=MeasureUsedDiskSpaceE
Group=DiskBarE
Meter=Bar
BarImage=bar.png
X=61
Y=3R
SolidColor=127,127,127,255
BarOrientation=Horizontal

;--------------------------- F ---------------------------
[MeterDriveInfoF]
Meter=String
Group=DiskF
MeterStyle=Style
MeasureName=MeasureDiskLabelF
MeasureName2=MeasureFreeDiskSpaceF
X=151
Y=10r
StringAlign=Center
AntiAlias=1
Percentual=1
Text="F:\ (%1) Free %2%"

[MeterUsedDriveBarF]
MeasureName=MeasureUsedDiskSpaceF
Group=DiskBarF
Meter=Bar
BarImage=bar.png
X=61
Y=3R
SolidColor=127,127,127,255
BarOrientation=Horizontal

;----------------------- G ---------------------------
[MeterDriveInfoG]
Meter=String
Group=DiskG
MeterStyle=Style
MeasureName=MeasureDiskLabelG
MeasureName2=MeasureFreeDiskSpaceG
X=151
Y=10r
StringAlign=Center
AntiAlias=1
Percentual=1
Text="G:\ (%1) Free %2%"

[MeterUsedDriveBarG]
MeasureName=MeasureUsedDiskSpaceG
Group=DiskBarG
Meter=Bar
BarImage=bar.png
X=61
Y=3R
SolidColor=127,127,127,255
BarOrientation=Horizontal

;------------------------- H ---------------------------
[MeterDriveInfoH]
Meter=String
Group=DiskH
MeterStyle=Style
MeasureName=MeasureDiskLabelH
MeasureName2=MeasureFreeDiskSpaceH
X=151
Y=10r
StringAlign=Center
AntiAlias=1
Percentual=1
Text="H:\ (%1) Free %2%"

[MeterUsedDriveBarH]
MeasureName=MeasureUsedDiskSpaceH
Group=DiskBarH
Meter=Bar
BarImage=bar.png
X=61
Y=3R
SolidColor=127,127,127,255
BarOrientation=Horizontal
I started doing this, not exactly what you need but it might help, will look later to see if I can get it more towards what you want

This is the bar image I used
bar.png
You do not have the required permissions to view the files attached to this post.
The only source of knowledge is experience. Albert Einstein
Deviant Art Page
User avatar
jsmorley
Developer
Posts: 19457
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Need help to code a USB Meter - Please

jsmorley » September 7th, 2019, 4:06 pm

You really can't have some kind of "style" that can create or remove measures and / or meters on the fly. You really HAVE to create all the measures and meters that you can possibly need, then just "hide" the meters you don't want to use.

Take a look at this code:

Code: Select all

[Rainmeter]
Update=1000
SkinWidth=176
BackgroundMode=2
SolidColor=150,150,150,150
AccurateText=1
DynamicWindowSize=1
MiddleMouseUpAction=!Refresh

[Metadata]
Name=e+
Author=jsmorley,ikarus1969, me 
Information=Measures attached USB Drives
Version=1.0
License=Creative Commons Attribution-Non-Commercial-Share Alike 3.0

;============ Variables

[Variables]
FONT=avenir lt 65 medium
COLOR=255,255,255
COLORDIAG=255,255,255,190
COLORHDD=255,255,255,160
COLORHDDBG=255,255,255,95
COLORS=255,255,255,170
COLORBACK=255,255,255,95
COLORGRAPH=255,255,255,70

;============ Drive Titles

Drive1=G:
Drive2=D:
Drive3=G:
Drive4=H:

;======== STYLES

[StyleAll]
FontFace=#FONT#
FontColor=#COLOR#
SolidColor=0,0,0,1
AntiAlias=1

[StyleLeft]
StringAlign=Left
FontSize=8

[StyleCenter]
StringAlign=Center
FontSize=8

[StyleCenter_HDD-Value]
StringAlign=Center
FontSize=7

[StyleCenter_DiskAccess]
StringAlign=Center
FontSize=7

; ===============
; ====== MEASURES
; ===============

; ====== Drive 1 Measures

[MeasureTypeDrive1]
Measure=FreeDiskSpace
Drive=#Drive1#
Type=1
IgnoreRemovable=0
UpdateDivider=2
IfMatch=Removed
IfMatchAction=[!HideMeterGroup Group1]
IfNotMatchAction=[!ShowMeterGroup Group1]

[MeasureLabelDrive1]
Measure=FreeDiskSpace
Drive=#Drive1#
Label=1
IgnoreRemovable=0
UpdateDivider=2

[MeasureTotalDrive1]
Measure=FreeDiskSpace
Drive=#Drive1#
Total=1
IgnoreRemovable=0
DiskQuota=1
UpdateDivider=2

[MeasureFreeDrive1]
Measure=FreeDiskSpace
Drive=#Drive1#
IgnoreRemovable=0
DiskQuota=1
UpdateDivider=2

[MeasureUsedDrive1]
Measure=FreeDiskSpace
Drive=#Drive1#
InvertMeasure=1
IgnoreRemovable=0
DiskQuota=1
UpdateDivider=2

[MeasureDrive1Reads]
Measure=Plugin
Plugin=UsageMonitor
Category=LogicalDisk
Counter=Disk Reads/sec
Name=#Drive1#

[MeasureDrive1Writes]
Measure=Plugin
Plugin=UsageMonitor
Category=LogicalDisk
Counter=Disk Writes/sec
Name=#Drive1#

; ====== Drive 2 Measures

[MeasureTypeDrive2]
Measure=FreeDiskSpace
Drive=#Drive2#
Type=1
IgnoreRemovable=0
UpdateDivider=2
IfMatch=Removed
IfMatchAction=[!HideMeterGroup Group2]
IfNotMatchAction=[!ShowMeterGroup Group2]

[MeasureLabelDrive2]
Measure=FreeDiskSpace
Drive=#Drive2#
Label=1
IgnoreRemovable=0
UpdateDivider=2

[MeasureTotalDrive2]
Measure=FreeDiskSpace
Drive=#Drive2#
Total=1
IgnoreRemovable=0
DiskQuota=1
UpdateDivider=2

[MeasureFreeDrive2]
Measure=FreeDiskSpace
Drive=#Drive2#
IgnoreRemovable=0
DiskQuota=1
UpdateDivider=2

[MeasureUsedDrive2]
Measure=FreeDiskSpace
Drive=#Drive2#
InvertMeasure=1
IgnoreRemovable=0
DiskQuota=1
UpdateDivider=2

[MeasureDrive2Reads]
Measure=Plugin
Plugin=UsageMonitor
Category=LogicalDisk
Counter=Disk Reads/sec
Name=#Drive2#

[MeasureDrive2Writes]
Measure=Plugin
Plugin=UsageMonitor
Category=LogicalDisk
Counter=Disk Writes/sec
Name=#Drive2#

; =============
; ====== METERS
; =============

; ====== Header Meter

[MeterStyleTransfer]
Meter=STRING
MeterStyle=StyleAll | StyleCenter
X=88
Y=5
Text=[  TRANSFERS  ]

; ======= Drive 1 Meters

[MeterLabelDrive1] 
Meter=STRING
Group=Group1
MeasureName=MeasureLabelDrive1
MeterStyle=StyleAll | StyleCenter
X=88
Y=5R
Text=[ #Drive1# ]
ToolTipText=%1
LeftMouseUpAction=["#Drive1#"]

[DriveMeterBarDrive1]
Meter=BAR
Group=Group1
MeasureName=MeasureUsedDrive1
X=37
Y=2R
W=100
H=3
BarOrientation=HORIZONTAL
BarColor=#COLORS#

[DriveMeterBarInvertDrive1]
Meter=BAR
Group=Group1
MeasureName=MeasureFreeDrive1
X=37
Y=0r
W=100
H=3
BarOrientation=HORIZONTAL
Flip=1
BarColor=#Colorback#

[MeterPercentDrive1]
Meter=STRING
Group=Group1
MeasureName=MeasureFreeDrive1
MeterStyle=StyleAll | StyleLeft
X=5R
Y=-7r
Text=%1%
Percentual=1

[MeasureValuesDrive1]
Meter=String
Group=Group1
MeterStyle=StyleAll | StyleCenter_HDD-Value
MeasureName=MeasureFreeDrive1
MeasureName2=MeasureTotalDrive1
X=88
Y=0R
Text=%1B Free of %2B Total
NumOfDecimals=1
AutoScale=1

[MeterDiskAccessDrive1]
Meter=String
Group=Group1
MeterStyle=StyleAll | StyleCenter_DiskAccess
MeasureName=MeasureDrive1Reads
MeasureName2=MeasureDrive1Writes
X=88
Y=0R
AutoScale=1
DynamicVariables=1
Text=Reads: [MeasureDrive1Reads:1]B/sec | Writes: [MeasureDrive1Writes:1]B/sec

; ======= Drive 2 Meters

[MeterLabelDrive2] 
Meter=STRING
Group=Group2
MeasureName=MeasureLabelDrive2
MeterStyle=StyleAll | StyleCenter
X=88
Y=5R
Text=[ #Drive2# ]
ToolTipText=%1
LeftMouseUpAction=["#Drive2#"]

[DriveMeterBarDrive2]
Meter=BAR
Group=Group2
MeasureName=MeasureUsedDrive2
X=37
Y=2R
W=100
H=3
BarOrientation=HORIZONTAL
BarColor=#COLORS#

[DriveMeterBarInvertDrive2]
Meter=BAR
Group=Group2
MeasureName=MeasureFreeDrive2
X=37
Y=0r
W=100
H=3
BarOrientation=HORIZONTAL
Flip=1
BarColor=#Colorback#

[MeterPercentDrive2]
Meter=STRING
Group=Group2
MeasureName=MeasureFreeDrive2
MeterStyle=StyleAll | StyleLeft
X=5R
Y=-7r
Text=%1%
Percentual=1

[MeasureValuesDrive2]
Meter=String
Group=Group2
MeterStyle=StyleAll | StyleCenter_HDD-Value
MeasureName=MeasureFreeDrive2
MeasureName2=MeasureTotalDrive2
X=88
Y=0R
Text=%1B Free of %2B Total
NumOfDecimals=1
AutoScale=1

[MeterDiskAccessDrive2]
Meter=String
Group=Group2
MeterStyle=StyleAll | StyleCenter_DiskAccess
MeasureName=MeasureDrive2Reads
MeasureName2=MeasureDrive2Writes
X=88
Y=0R
AutoScale=1
DynamicVariables=1
Text=Reads: [MeasureDrive2Reads:1]B/sec | Writes: [MeasureDrive2Writes:1]B/sec


; ======= Footer Meter

[MeterFooter]
Meter=Image
W=176
H=10
Y=0R

1.jpg

If a drive is removed, it will just "hide" all its associated meters, and the ones below it will move up.

Just add more sets of measures and meters as desired. They are all set "relative" to each other, so you shouldn't have to do much if anything with any "Y" options on them. Just be sure to follow the "Drive(N)" naming convention. The critical bit here is that ALL the meters have a "Y" position that is "relative" to the meter(s) above it. Don't set any static "Y" options.

I tweaked some other things as well...
You do not have the required permissions to view the files attached to this post.
User avatar
jsmorley
Developer
Posts: 19457
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Need help to code a USB Meter - Please

jsmorley » September 8th, 2019, 11:38 am

Now, once you see how that works, here is a version of the skin that might make it a bit easier to follow and to maintain.

DriveINC_1.0.rmskin

Take a look at this. What I did was to separate out the distinct Drive(N) Measure and Meter sections into individual .inc @Include files, and then just stick the call to the @Include(s) in the skin where I want them to appear.

Code: Select all

[Rainmeter]
Update=1000
SkinWidth=176
BackgroundMode=2
SolidColor=150,150,150,150
AccurateText=1
DynamicWindowSize=1
MiddleMouseUpAction=!Refresh

[Metadata]
Name=e+
Author=jsmorley,ikarus1969, me 
Information=Measures attached USB Drives
Version=1.0
License=Creative Commons Attribution-Non-Commercial-Share Alike 3.0

;============ Variables

[Variables]
Drive1=C:
Drive2=D:
Drive3=E:
Drive4=G:

@IncludeColors=#@#Font&Colors.inc
@IncludeStyles=#@#MeterStyles.inc

; ====== Header Meter

[MeterStyleTransfer]
Meter=String
MeterStyle=StyleAll | StyleCenter
X=88
Y=5
Text=[  TRANSFERS  ]

; ====== Drive Measures and Meters

@Include1=#@#Drive1.inc

@Include2=#@#Drive2.inc

@Include3=#@#Drive3.inc

@Include4=#@#Drive4.inc

; ======= Footer Meter

[MeterFooter]
Meter=Image
W=176
H=10
Y=0R
Just add in as many distinct @Include(N) lines as you need for the number of drives you want to support. Feel free to create and add Drive5.inc ... Drive26.inc files as you need. This does mean that if you change something in either the Measures (unlikely) or the Meters (likely), you will need to do the same thing in each of the Drive(N) @Include files.
You do not have the required permissions to view the files attached to this post.
dfghrngsdkg
Posts: 19
Joined: February 16th, 2019, 8:40 pm

Re: Need help to code a USB Meter - Please

dfghrngsdkg » September 8th, 2019, 2:17 pm

jsmorley wrote:
September 7th, 2019, 4:06 pm
You really can't have some kind of "style" that can create or remove measures and / or meters on the fly. You really HAVE to create all the measures and meters that you can possibly need, then just "hide" the meters you don't want to use.

Take a look at this code:

Code: Select all

[Rainmeter]
Update=1000
SkinWidth=176
BackgroundMode=2
SolidColor=150,150,150,150
AccurateText=1
DynamicWindowSize=1
MiddleMouseUpAction=!Refresh

[Metadata]
Name=e+
Author=jsmorley,ikarus1969, me 
Information=Measures attached USB Drives
Version=1.0
License=Creative Commons Attribution-Non-Commercial-Share Alike 3.0

;============ Variables

[Variables]
FONT=avenir lt 65 medium
COLOR=255,255,255
COLORDIAG=255,255,255,190
COLORHDD=255,255,255,160
COLORHDDBG=255,255,255,95
COLORS=255,255,255,170
COLORBACK=255,255,255,95
COLORGRAPH=255,255,255,70

;============ Drive Titles

Drive1=G:
Drive2=D:
Drive3=G:
Drive4=H:

;======== STYLES

[StyleAll]
FontFace=#FONT#
FontColor=#COLOR#
SolidColor=0,0,0,1
AntiAlias=1

[StyleLeft]
StringAlign=Left
FontSize=8

[StyleCenter]
StringAlign=Center
FontSize=8

[StyleCenter_HDD-Value]
StringAlign=Center
FontSize=7

[StyleCenter_DiskAccess]
StringAlign=Center
FontSize=7

; ===============
; ====== MEASURES
; ===============

; ====== Drive 1 Measures

[MeasureTypeDrive1]
Measure=FreeDiskSpace
Drive=#Drive1#
Type=1
IgnoreRemovable=0
UpdateDivider=2
IfMatch=Removed
IfMatchAction=[!HideMeterGroup Group1]
IfNotMatchAction=[!ShowMeterGroup Group1]

[MeasureLabelDrive1]
Measure=FreeDiskSpace
Drive=#Drive1#
Label=1
IgnoreRemovable=0
UpdateDivider=2

[MeasureTotalDrive1]
Measure=FreeDiskSpace
Drive=#Drive1#
Total=1
IgnoreRemovable=0
DiskQuota=1
UpdateDivider=2

[MeasureFreeDrive1]
Measure=FreeDiskSpace
Drive=#Drive1#
IgnoreRemovable=0
DiskQuota=1
UpdateDivider=2

[MeasureUsedDrive1]
Measure=FreeDiskSpace
Drive=#Drive1#
InvertMeasure=1
IgnoreRemovable=0
DiskQuota=1
UpdateDivider=2

[MeasureDrive1Reads]
Measure=Plugin
Plugin=UsageMonitor
Category=LogicalDisk
Counter=Disk Reads/sec
Name=#Drive1#

[MeasureDrive1Writes]
Measure=Plugin
Plugin=UsageMonitor
Category=LogicalDisk
Counter=Disk Writes/sec
Name=#Drive1#

; ====== Drive 2 Measures

[MeasureTypeDrive2]
Measure=FreeDiskSpace
Drive=#Drive2#
Type=1
IgnoreRemovable=0
UpdateDivider=2
IfMatch=Removed
IfMatchAction=[!HideMeterGroup Group2]
IfNotMatchAction=[!ShowMeterGroup Group2]

[MeasureLabelDrive2]
Measure=FreeDiskSpace
Drive=#Drive2#
Label=1
IgnoreRemovable=0
UpdateDivider=2

[MeasureTotalDrive2]
Measure=FreeDiskSpace
Drive=#Drive2#
Total=1
IgnoreRemovable=0
DiskQuota=1
UpdateDivider=2

[MeasureFreeDrive2]
Measure=FreeDiskSpace
Drive=#Drive2#
IgnoreRemovable=0
DiskQuota=1
UpdateDivider=2

[MeasureUsedDrive2]
Measure=FreeDiskSpace
Drive=#Drive2#
InvertMeasure=1
IgnoreRemovable=0
DiskQuota=1
UpdateDivider=2

[MeasureDrive2Reads]
Measure=Plugin
Plugin=UsageMonitor
Category=LogicalDisk
Counter=Disk Reads/sec
Name=#Drive2#

[MeasureDrive2Writes]
Measure=Plugin
Plugin=UsageMonitor
Category=LogicalDisk
Counter=Disk Writes/sec
Name=#Drive2#

; =============
; ====== METERS
; =============

; ====== Header Meter

[MeterStyleTransfer]
Meter=STRING
MeterStyle=StyleAll | StyleCenter
X=88
Y=5
Text=[  TRANSFERS  ]

; ======= Drive 1 Meters

[MeterLabelDrive1] 
Meter=STRING
Group=Group1
MeasureName=MeasureLabelDrive1
MeterStyle=StyleAll | StyleCenter
X=88
Y=5R
Text=[ #Drive1# ]
ToolTipText=%1
LeftMouseUpAction=["#Drive1#"]

[DriveMeterBarDrive1]
Meter=BAR
Group=Group1
MeasureName=MeasureUsedDrive1
X=37
Y=2R
W=100
H=3
BarOrientation=HORIZONTAL
BarColor=#COLORS#

[DriveMeterBarInvertDrive1]
Meter=BAR
Group=Group1
MeasureName=MeasureFreeDrive1
X=37
Y=0r
W=100
H=3
BarOrientation=HORIZONTAL
Flip=1
BarColor=#Colorback#

[MeterPercentDrive1]
Meter=STRING
Group=Group1
MeasureName=MeasureFreeDrive1
MeterStyle=StyleAll | StyleLeft
X=5R
Y=-7r
Text=%1%
Percentual=1

[MeasureValuesDrive1]
Meter=String
Group=Group1
MeterStyle=StyleAll | StyleCenter_HDD-Value
MeasureName=MeasureFreeDrive1
MeasureName2=MeasureTotalDrive1
X=88
Y=0R
Text=%1B Free of %2B Total
NumOfDecimals=1
AutoScale=1

[MeterDiskAccessDrive1]
Meter=String
Group=Group1
MeterStyle=StyleAll | StyleCenter_DiskAccess
MeasureName=MeasureDrive1Reads
MeasureName2=MeasureDrive1Writes
X=88
Y=0R
AutoScale=1
DynamicVariables=1
Text=Reads: [MeasureDrive1Reads:1]B/sec | Writes: [MeasureDrive1Writes:1]B/sec

; ======= Drive 2 Meters

[MeterLabelDrive2] 
Meter=STRING
Group=Group2
MeasureName=MeasureLabelDrive2
MeterStyle=StyleAll | StyleCenter
X=88
Y=5R
Text=[ #Drive2# ]
ToolTipText=%1
LeftMouseUpAction=["#Drive2#"]

[DriveMeterBarDrive2]
Meter=BAR
Group=Group2
MeasureName=MeasureUsedDrive2
X=37
Y=2R
W=100
H=3
BarOrientation=HORIZONTAL
BarColor=#COLORS#

[DriveMeterBarInvertDrive2]
Meter=BAR
Group=Group2
MeasureName=MeasureFreeDrive2
X=37
Y=0r
W=100
H=3
BarOrientation=HORIZONTAL
Flip=1
BarColor=#Colorback#

[MeterPercentDrive2]
Meter=STRING
Group=Group2
MeasureName=MeasureFreeDrive2
MeterStyle=StyleAll | StyleLeft
X=5R
Y=-7r
Text=%1%
Percentual=1

[MeasureValuesDrive2]
Meter=String
Group=Group2
MeterStyle=StyleAll | StyleCenter_HDD-Value
MeasureName=MeasureFreeDrive2
MeasureName2=MeasureTotalDrive2
X=88
Y=0R
Text=%1B Free of %2B Total
NumOfDecimals=1
AutoScale=1

[MeterDiskAccessDrive2]
Meter=String
Group=Group2
MeterStyle=StyleAll | StyleCenter_DiskAccess
MeasureName=MeasureDrive2Reads
MeasureName2=MeasureDrive2Writes
X=88
Y=0R
AutoScale=1
DynamicVariables=1
Text=Reads: [MeasureDrive2Reads:1]B/sec | Writes: [MeasureDrive2Writes:1]B/sec


; ======= Footer Meter

[MeterFooter]
Meter=Image
W=176
H=10
Y=0R


1.jpg


If a drive is removed, it will just "hide" all its associated meters, and the ones below it will move up.

Just add more sets of measures and meters as desired. They are all set "relative" to each other, so you shouldn't have to do much if anything with any "Y" options on them. Just be sure to follow the "Drive(N)" naming convention. The critical bit here is that ALL the meters have a "Y" position that is "relative" to the meter(s) above it. Don't set any static "Y" options.

I tweaked some other things as well...
Hello jsmorley,

First of all Thank you for looking into this matter and the Code itself plus the tweaks you made. You had achieved in 20min+ what I was trying to put together in two weekends = approx. 50h of nothing. The Meter is what I was looking for. What stuns me is of how clean, neat and compressed its look is and thus unearths a lot of new question, but let me start from the beginning.

1. In other Codes and also yours -on which my Meter was/is based on- I noticed that the [StyleBar] contains only the following: X=5, Y=2R, W=190, H=2, Orientation + Color and its linked [mBarDisk1] the values of: Meter=Bar, MeterStyle=StyleBar, Group=Disk1 and MeasureName=mUsedDisk1.
The latter (MeasureName=mUsedDisk1) was the part I didn't understood as I wrongly thought that replacing "mUsedDisk1" with my "MeasureStyleBar" that contains already measuring Meters of mine stuffed together will make the [mBarDisk1] do of what was expected. Therefore it appeared logical to me that 1st. I have to have a "Style" containing x,y,h,w, color and orientation for its position to then >> 2nd. create a [MeterStyleBar] with its functions of measuring #Drive1#, #Drive1_Free#, etc.) and 3rd. to create a [MeasureStyleBar] where I can plug in these interchangeable Meters and thus able to draw its design from the same source with me being able to only have to alter the DriveNames and then transfer the whole set wherever I like it to be by only changing the [MeasureStyleBar]'s x and y coordinates. Here a visual example of my attempt:

Code: Select all

[StyleBar_USED]
Meter=BAR
X=37
Y=54
W=100
H=3
BarOrientation=HORIZONTAL
BarColor=#COLORS#
+

Code: Select all

[DriveMeterBar]
MeterStyle=StyleBar_USED
MeasureName=MeasureDrive1_USED
Meter=BAR

placed inside a combining Measurement it became this:

Code: Select all

[MeasureBarDrive1]
Meter=Bar
Group=Drive1
MeterStyle1=StyleBar_USED
MeterStyle2=StyleBar_FREE
MeterStyle3=StyleDrivePercentage
MeterStyle4=StyleTransfer
MeterStlye5=StyleLabelDrive
MeterStyle6=StyleBlock
MeasureName1=MeasureDrive1_USED
MeasureName2=MeasureDrive1_FREE
MeasureName3=MeasureDrive1_FREE
Obviously a failure, but with good intentions.

===========

2. Comparing your way of coding, it looks sophisticated and different from what I used to see and work with. For example: [StylesLeft]. It usually includes: FontFace, Color, Alignment, Size, Color whereas yours comes only with Alignment and FontSize and till now I can't figure out of how the [Style], with this less of information, is able to retrieve the other values from the [Variables]-Table. Same goes for the various Colors I use on the Bars (White and Gray-Transparent) as I can't see where it is linked to. It's like .. "magic"?

Another part are the "If" variables.

Code: Select all

IfMatch=Removed
IfMatchAction=[!HideMeterGroup Group1]
IfNotMatchAction=[!ShowMeterGroup Group1]

Different to others who use [IfAboveValue=1] or "IfCondition=" that is followed by tons of values to "!SetOptionShowMeter", "!SetOptionHide...", and also different to your original code I used (from the link in my first post), this time it is even more shorter but still works the same way. The "Measures" now also contain (new to me) elements e.g. "DiskQuota=1", "Type=1" and else of which I have to wrap my brain around first by looking up its meanings and functions in the RM-Manual but nevertheless, in its inter-play it's functioning. I understand that there are many ways to code and that yours is that of a professional plus an overall continuous developments in coding ,but still I am baffled. A steep learning-curve for me, hard to catch up.

===========

Aside of this I do have some additional questions.

1. Once, while I tinkered with different codes, I somehow managed to make a Drive's given name to appear. For example [E:] then showed the Drive as: [Win7_x64_Bootstick] which is the name I had given the Drive. However, I couldn't figure out of how I did and since this occurrence I couldn't reproduce this little feature. The Question now is: Is there a "Meter/MeasureName=xyz" that can retrieve a Drive's name when plugged in and where to put it?

2. I had a [MeasureColorBar] included that is meant to turn the Bar into Red when only 10% of free space is left. If I (re)include it, do I have to add the command: "Group=Group1", "Group=Group2" (depend on the amount of Drives)?

3. When no Drive is plugged in the [TRANSFERS] Bar still stays on my Desktop. In order to hide it, I included: "Group=Group1" with the same I've done to the Footer. Even so, there is a Bar left but I don't know where this Bar is coming from. I know, that if I turn the "BackgroundMode" to 1 and set the color to 0,0,0,1 it will disappear but still curious where this bar is linked to and how to turn it off. I had disabled everything with the result that the bar gets smaller and in the end larger again showing some -I believe- Typo or something.
3.1. To hide the TRANSFERS-BAR and Footer when two Drives are attached, do I need to add a: "Group1=Group2" to each, the TRANSFERS-Bar and the Footer, or is it not of importance since the last Drive unplugged will shut down the whole Meter anyway?

4. If I want to have my Prefix and Postfix larger, how do I do this?
I know I can possibly create a [StylePrefix] like this:

Code: Select all

[StylePrefix]
Meter=String
FontFace=#FONT#			
MeterStyle=StyleLeft
AntiAlias=1
FontSize=10
Text=[

but I do not know of how to place it in the "[MeterStyleTransfer]" Table.
If I type: "MeterStyle=MeterStylePrefix" I not get the result and writing like:
Prefix=#MeterStylePrefix# doesn't work either.


For closure I want to say, "Thank you" again and -this time for sure- I want to apologize for being a bit salty in yesterday's post. It wasn't meant to be. It was frustration because of the time I've invested in relation to its meager outcome. When I had started this project I was full of enthusiasm that, over the course of time and with the backlashes that grinded me to halt, then gradually turned into a frustrating anger. My human nature.

For your second post, I'll to take a look into and reach out after that.

With kind regards,
dfghrngsdkg
Posts: 19
Joined: February 16th, 2019, 8:40 pm

Re: Need help to code a USB Meter - Please

dfghrngsdkg » September 13th, 2019, 11:47 am

Hello,

so I took a bit of my time and had started to look into your latest skin you kindly had provided. It is giving me indeed a better understanding now, even if I still have a bit of the [r] vs [R] trouble, some codes I have to get used to as well as on how to arrange the files and some things still puzzle me like: How you retrieve the information in e.g. "StyleLeft". I also get a better understanding now of how the .inc system works (in streamlining a .ini. while simultaneous keeping it the most flexible). Some of the questions I ask in my last post I could also solve by myself, thanks to your build and so I have only two questions left.

1. Is there a "Meter/MeasureName=xyz" that can retrieve/extract a Drive's given name when it is plugged in?

2. How can I create and put a [StylePrefix] into a Meter? I ask because I want to have the Pre- and Postfix slightly larger than the Text that is shown with the Meter. Therefore I've created a code (hope it is correct) that looks like this:

Code: Select all

[StylePrefix]
Meter=String
FontFace=#FONT#			
MeterStyle=StyleLeft
AntiAlias=1
FontSize=10
Text=[
The issue I have is that I do not know of how to place it in the then "[MeterStyleTransfer]" Table. No matter if I type: "MeterStyle=MeterStylePrefix" or "Prefix=#MeterStylePrefix#" the result is non as it would show the command but not the enlarged "[". It would be nice if you could explain it to me.

With kind regards,