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