It is currently March 29th, 2024, 9:25 am

Need help to code a USB Meter - Please

Get help with creating, editing & fixing problems with skins
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Need help to code a USB Meter - Please

Post by jsmorley »

dfghrngsdkg wrote: September 13th, 2019, 11:47 am 1. Is there a "Meter/MeasureName=xyz" that can retrieve/extract a Drive's given name when it is plugged in?

Code: Select all

[MeasureLabelDrive1]
Measure=FreeDiskSpace
Drive=#Drive1#
Label=1
IgnoreRemovable=0
UpdateDivider=2
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.

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[Variables]
Drive1=C:

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

[StyleLeft]
StringAlign=Left
Text=[  #Drive1#  %1  ]

[MeterOne]
Meter=String
MeasureName=MeasureLabelDrive1
MeterStyle=StyleLeft
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1

1.jpg

I don't recommend Prefix and / or Postfix. Ever. Those are prehensile tail functions left over from when the Text option was less capable than it is today.
You do not have the required permissions to view the files attached to this post.
dfghrngsdkg
Posts: 43
Joined: February 16th, 2019, 8:40 pm

Re: Need help to code a USB Meter - Please

Post by dfghrngsdkg »

About the "MeasureName" :
Its odd as the part of the code you provided ([MeasureLabelDrive1]) is already part of the .ini file. It must have something to do with [MeterOne]. For now it still reads E: instead of the Name of the Drive and instead does replace the headder : [TRANSFERS] with the Drive's Name. Lets see how I can fix this.

About Pre- and Postfix:
I see, so all this Prefix/Postfix I come across is outdated. I didn't know this but good to know now.

About the Brackets ([ ]) I want to use: In your file both Text and Brackets having the same size. Probably because you got me wrong here (due to my incorrect explanation). The aim is to have larger Brackets (FontSize=15) whereas the Text inside stays at FontSize=8. The Code below provides what I made so far with both, the Text and the Brackets. However, the Text does not show up inside the Brackets which I do not understand if I: " " or # # . What did I miss?

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[Variables]
;Drive1=C:


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


[StyleBrackets]
FontFace=#FONT#
StringAlign=Center
FontColor=#COLOR#
Padding=5,5,5,5
FontSize=15


;====

[MeterStyleBrackets]
Meter=STRING
MeterStyle=StyleBrackets
Text=[ "StyleText" ]
X=88
Y=5

[StyleText]
Meter=String
MeterStyle=StyleCenter
Text="TRANSFERS"
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Need help to code a USB Meter - Please

Post by jsmorley »

dfghrngsdkg wrote: September 13th, 2019, 3:05 pm About the "MeasureName" :
Its odd as the part of the code you provided ([MeasureLabelDrive1]) is already part of the .ini file. It must have something to do with [MeterOne]. For now it still reads E: instead of the Name of the Drive and instead does replace the headder : [TRANSFERS] with the Drive's Name. Lets see how I can fix this.

About Pre- and Postfix:
I see, so all this Prefix/Postfix I come across is outdated. I didn't know this but good to know now.

About the Brackets ([ ]) I want to use: In your file both Text and Brackets having the same size. Probably because you got me wrong here (due to my incorrect explanation). The aim is to have larger Brackets (FontSize=15) whereas the Text inside stays at FontSize=8. The Code below provides what I made so far with both, the Text and the Brackets. However, the Text does not show up inside the Brackets which I do not understand if I: " " or # # . What did I miss?

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[Variables]
;Drive1=C:


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


[StyleBrackets]
FontFace=#FONT#
StringAlign=Center
FontColor=#COLOR#
Padding=5,5,5,5
FontSize=15


;====

[MeterStyleBrackets]
Meter=STRING
MeterStyle=StyleBrackets
Text=[ "StyleText" ]
X=88
Y=5

[StyleText]
Meter=String
MeterStyle=StyleCenter
Text="TRANSFERS"

Getting the [ and ] characters to be a different font size is pretty trivial:

Code: Select all

[MeterOne]
Meter=String
MeasureName=MeasureLabelDrive1
MeterStyle=StyleLeft
FontSize=8
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
InlineSetting=Size | 11
InlinePattern=\[|\]
https://docs.rainmeter.net/manual/meters/string/inline/

Note that I "escaped" \ the [ and ] characters as they are reserved characters in regular expression, and must be escaped to use as a literal.

However, there is no inline setting for how various parts of a single meter are positioned vertically relative to each other, the Y setting will always be the "bottom / baseline" of the font glyph. In this case, since there is some "slack space" at the bottom of the letters that isn't there on the bottom of the brackets, it works out pretty well.

1.jpg

This may not always be the case if you are mixing sizes with just letters, and even with what you are doing, it depends somewhat on what font you are using.
You do not have the required permissions to view the files attached to this post.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Need help to code a USB Meter - Please

Post by jsmorley »

dfghrngsdkg wrote: September 13th, 2019, 3:05 pm About the "MeasureName" :
Its odd as the part of the code you provided ([MeasureLabelDrive1]) is already part of the .ini file. It must have something to do with [MeterOne]. For now it still reads E: instead of the Name of the Drive and instead does replace the headder : [TRANSFERS] with the Drive's Name. Lets see how I can fix this.
Don't take my examples as what you literally should do in your skin. They are just examples of "how" you might approach what you are trying to do, and I am paying no attention at all to what code you do or don't have written already. You want to work the "ideas" I'm laying out into what you are trying to do.

For instance, I put the InlineSetting / InlinePattern options into the example meter, just cause that was easier for me. You could put those setting in a MeterStyle if you want, up to you.
dfghrngsdkg
Posts: 43
Joined: February 16th, 2019, 8:40 pm

Re: Need help to code a USB Meter - Please

Post by dfghrngsdkg »

Hello,

It's a bit since my last post but want to say thank you -to both of you. Everything works now as intended except that my mobile not shows up when connected via cable > USB-Port (any Idea?). I'll going to post the final version here for everyone to use later on. Just one last, final question: Is there an: "RightMouseUPAction=" that can eject a Drive -like in the Taskbars's IconTray? If positive, where to find and if not, will there be one in the future? I find a such feature would be great.

With kind regards,
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Need help to code a USB Meter - Please

Post by balala »

dfghrngsdkg wrote: September 24th, 2019, 10:40 am Just one last, final question: Is there an: "RightMouseUPAction=" that can eject a Drive -like in the Taskbars's IconTray? If positive, where to find and if not, will there be one in the future? I find a such feature would be great.
Natively Rainmeter can't do this, but you can use an external addon or a plugin.
I recommend using the UDisk plugin. If you want to give it a try, first you have to install the plugin. Download and install the UDisk_0.9.1.rmskin skin from the above link. The installer beside the skin, installs the appropriate version of the plugin as well.
If you got the plugin installed, add the following measure to your code:

Code: Select all

[MeasureUDisk]
Measure=Plugin
Plugin=UDisk
Drive=Removable
Mode=MultiThread
This measure returns the list of the removable drives as string value and the number of these drives as numeric value. Now using this measure you can remove the drive, using the following bang, added to the RightMouseUpAction option: RightMouseUpAction=[!CommandMeasure "MeasureUDisk" "Remove_X:"]. Take care to replace the X: character with the appropriate drive letter in this bang.
There are other possibilities as well. One of them requires using the RemoveDrive addon, available here.
Please let me know if you succeeded using the UDisk plugin or need further assitence to use other tool (RemoveDrive for instance).
dfghrngsdkg
Posts: 43
Joined: February 16th, 2019, 8:40 pm

Re: Need help to code a USB Meter - Please

Post by dfghrngsdkg »

Hello to all,

guess I've celebrated a bit to early and so I need a lending hand, but first comes first:

Thank you balala for your input. The UDisk plugin -after its installation- works well so far and no problems detected. However, I wonder if I only need the UDisk.dll (both, its 32 and 64 version) to keep this working on my win7 x64 Machine. What I did was to unload+uninstall UDisk and installed only the .DLL that came with the R-Skin (and sits now in C:\Users\xxx'\Documents\Rainmeter\Skins\@Vault\Plugins\UDisk\0.9.1.0.) . If so, can I move it permanently to Sys32 and WOW64 respectively?


Now let me explain two issues I am experiencing with the Skin:

1. Positioning of Removeable Drives:
My design is as you can see in the picture below. The trouble I have is its spacing underneath [ TRANSFERS ]. In the picture's Left you can see how it shall be (regarding the spacing) while in the Right picture you will see the problem that if I remove the first Drive (E:) the Drive that follows into the first Drive's position does not do so as it stops short. I know it has something to do with Y=xxR, but if I change that value to fit the 1st.Drive's position, the spacing between these two Drives changes (becomes too narrow when both attached) which I not want. How can I keep the spacing between the Drives while simultaneously make the following Drive to move into the 1st. Drive's Position (when removed)?

screen.JPG

;============

2. Show/Hide of the Header >> [ TRANSFERS ] << when multiple Drives are attached and removed:
I want [ TRANSFERS ] to show whenever I plug in USB-Drives and to hide when removing them. It works fine with a single Drive with the command: "Group=Group1" is added to the Drive's Meter in the .inc file and in the .ini file (underneath the Header's Style/Meter). But it doesn't work with two or more Drives even if I had added: "Group=Group2" to Drive F: and "Group=Group3" to Drive G: .inc files and also added to the .ini file respectively.
What happens instead is: If I remove E: the Header disappears even if a second and third Drive is attached. I tried many combination but to no avail and right now don't know how to make it work.

I suppose these two things are minor issues to you and therefore I like to ask if you can take a look at it, please?

For the Code:
jsmorley pointed me into the right direction by streamlining the .ini with use of .inc files. Since this had increased my files (containing the Drives.inc (5), + Meter.inc and variables.inc, I decided to make a single .ini with three Drives (C: + E: and F: as removable) for the purpose of examination/studying. So in case it works here, please point out what I have to change in my .inc files later on.

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,balala, 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=C:
Drive2=E:
Drive3=F:
Drive4=G:

;======== 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


[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 Group1]
IfNotMatchAction=[!ShowMeterGroup Group1]

[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#

;=== Eject

[MeasureUDisk]
Measure=Plugin
Plugin=UDisk
Drive=#Drive2#
Mode=MultiThread

; ====== Drive 3 Measures

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

[MeasureLabelDrive3]
Measure=FreeDiskSpace
Drive=#Drive3#
Label=1
IgnoreRemovable=0
UpdateDivider=2

[MeasureTotalDrive3]
Measure=FreeDiskSpace
Drive=#Drive3#
Total=1
IgnoreRemovable=0
DiskQuota=1
UpdateDivider=2

[MeasureFreeDrive3]
Measure=FreeDiskSpace
Drive=#Drive3#
IgnoreRemovable=0
DiskQuota=1
UpdateDivider=2

[MeasureUsedDrive3]
Measure=FreeDiskSpace
Drive=#Drive3#
InvertMeasure=1
IgnoreRemovable=0
DiskQuota=1
UpdateDivider=2

[MeasureDrive3Reads]
Measure=Plugin
Plugin=UsageMonitor
Category=LogicalDisk
Counter=Disk Reads/sec
Name=#Drive3#

[MeasureDrive3Writes]
Measure=Plugin
Plugin=UsageMonitor
Category=LogicalDisk
Counter=Disk Writes/sec
Name=#Drive3#

;=== Eject

[MeasureUDisk]
Measure=Plugin
Plugin=UDisk
Drive=#Drive3#
Mode=MultiThread

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

; ====== Header Meter

[MeterStyleTransfer]
Meter=STRING
;Group=Group1 | Group2
Group=1
Group=2
MeterStyle=StyleAll | StyleCenter
X=88
Y=73R
Text=[  TRANSFERS  ]


; ======= Drive 1 Meters

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

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

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

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

[MeasureValuesDrive1]
Meter=String
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
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=Group1
MeasureName=MeasureLabelDrive2
MeterStyle=StyleAll | StyleCenter
X=88
Y=50R
Text=[ #Drive2# ]
ToolTipText=%1
LeftMouseUpAction=["#Drive2#"]
RightMouseUpAction=[!CommandMeasure "MeasureUDisk" "Remove_#Drive2#"]

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

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

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

[MeasureValuesDrive2]
Meter=String
Group=Group1
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=Group1
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


; ======= Drive 3 Meters

[MeterLabelDrive3] 
Meter=STRING
Group=Group2
MeasureName=MeasureLabelDrive3
MeterStyle=StyleAll | StyleCenter
X=88
Y=12R
Text=[ #Drive3# ]
ToolTipText=%1
LeftMouseUpAction=["#Drive3#"]
RightMouseUpAction=[!CommandMeasure "MeasureUDisk" "Remove_#Drive3#"]

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

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

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

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

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





; ======= Footer Meter

[MeterFooter]
Group=Group1
Meter=Image
W=176
H=10
Y=0R
With kind regards,
You do not have the required permissions to view the files attached to this post.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Need help to code a USB Meter - Please

Post by balala »

dfghrngsdkg wrote: September 27th, 2019, 1:06 pm I wonder if I only need the UDisk.dll (both, its 32 and 64 version) to keep this working on my win7 x64 Machine. What I did was to unload+uninstall UDisk and installed only the .DLL that came with the R-Skin (and sits now in C:\Users\xxx'\Documents\Rainmeter\Skins\@Vault\Plugins\UDisk\0.9.1.0.) . If so, can I move it permanently to Sys32 and WOW64 respectively?
The plugin is the appropriate .dll file, which has to be installed into the c:\Users\xxx\AppData\Roaming\Rainmeter\Plugins\ folder. What you have into the C:\Users\xxx'\Documents\Rainmeter\Skins\@Vault\ folder is a "backup" of both versions (x86 and x64) of the installed plugins. The purpose of copying those into the @Vault folder is to have a copy of both versions, if anytime later you want to re-create the skin installer (https://docs.rainmeter.net/manual/distributing-skins/vault-folder/#VaultPlugins).
When a skin uses the plugin, it doesn't use the plugin from the @Vault folder, but, as said, from c:\Users\xxx\AppData\Roaming\Rainmeter\Plugins\. There sits the used plugins, into one single folder.
:17denial Don't move them. :17denial
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Need help to code a USB Meter - Please

Post by jsmorley »

1. Positioning of Removable Drives:
The problem is that when you make a meter relative to the previous meter with Y=10R for instance, then it is positioned 10 pixels below the "bottom" of the previous meter.

Now when a meter is "hidden", it has no "height", but it still has a "position" in vertical space, defined by the Y option. So if you add 10 pixels to the bottom of the meter, those 10 pixels are still added to the relative position of the second meter.

The point is, that if you have a meter using Y=10R, and you hide the meter above it, then the position of the second meter becomes 10. If you have a third meter below that, and you hide both of the ones above it, the position of the third meter will be 20.

The way to consider the "R" setting for relative positioning is that it means (AnyValue+[PreviousMeter:Y]+[PreviousMeter:H]). This means that when [PreviousMeter] is "hidden", it becomes (AnyValue+[PreviousMeter:Y]+0). What you are left with is whatever you have AnyValue set to.

What you need to do to avoid this is to try not to use any static value(s) in the relative position. What you want is that when a meter is "hidden", it has NO impact at all on subsequent meters.

Take a look at this example. There are lots of ways you can attack this, and this is just one, but it might point you in a direction that works for you.

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[Variables]

[MeterBack]
Meter=Shape
Shape=Rectangle 1,1,150,([Meter1:H]+[Meter2:H]+[Meter3:H]+[Meter4:H]+10) | Fill Color 47,47,47,255 | Stroke Color 255,255,255,255 | StrokeWidth 2
DynamicVariables=1
LeftMouseUpAction=[!ShowMeterGroup All][!UpdateMeter *][!Redraw]

[MeterContainer]
Meter=Shape
X=10
Y=10
Shape=Rectangle 1,1,150,[MeterBack:H] | Fill Color 0,0,0,255 | StrokeWidth 0
DynamicVariables=1

[Meter1]
Meter=String
Group=All
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,1
Padding=0,0,0,10
AntiAlias=1
Text=I'm meter 1
Container=MeterContainer
LeftMouseUpAction=[!ShowMeterGroup All][!HideMeter Meter1][!UpdateMeter *][!Redraw]

[Meter2]
Meter=String
Group=All
X=r
Y=R
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,1
Padding=0,0,0,10
AntiAlias=1
Text=I'm meter 2
Container=MeterContainer
LeftMouseUpAction=[!ShowMeterGroup All][!HideMeter Meter2][!UpdateMeter *][!Redraw]

[Meter3]
Meter=String
Group=All
X=r
Y=R
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,1
Padding=0,0,0,10
AntiAlias=1
Text=I'm meter 3
Container=MeterContainer
LeftMouseUpAction=[!ShowMeterGroup All][!HideMeter Meter3][!UpdateMeter *][!Redraw]

[Meter4]
Meter=String
Group=All
X=r
Y=R
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,1
Padding=0,0,0,10
AntiAlias=1
Text=I'm meter 4
Container=MeterContainer
LeftMouseUpAction=[!ShowMeterGroup All][!HideMeter Meter4][!UpdateMeter *][!Redraw]

GIF.gif


So I'm doing a few things.

First, I just use Y=R (or Y=0R) for each meter. This means they will be positioned relative to the bottom of the previous meter, with no extra "static" space between them.

Now we DO WANT some space between them, so to get that I use the Padding option to add some space to the "bottom" of each meter. The nice thing is that this space is also "hidden" (has no "height") when the meter is.

Then I use a Container to manage where all of this appears in the skin. I don't want any special X or Y on the very first meter, as things won't look right when IT is hidden. So I use the container to position the entire set of meters in a starting X and Y.

https://docs.rainmeter.net/manual/meters/general-options/#XY
https://docs.rainmeter.net/manual/meters/general-options/#Padding
https://docs.rainmeter.net/manual/meters/general-options/container/
You do not have the required permissions to view the files attached to this post.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Need help to code a USB Meter - Please

Post by balala »

dfghrngsdkg wrote: September 27th, 2019, 1:06 pm 2. Show/Hide of the Header >> [ TRANSFERS ] << when multiple Drives are attached and removed:
I want [ TRANSFERS ] to show whenever I plug in USB-Drives and to hide when removing them. It works fine with a single Drive with the command: "Group=Group1" is added to the Drive's Meter in the .inc file and in the .ini file (underneath the Header's Style/Meter). But it doesn't work with two or more Drives even if I had added: "Group=Group2" to Drive F: and "Group=Group3" to Drive G: .inc files and also added to the .ini file respectively.
What happens instead is: If I remove E: the Header disappears even if a second and third Drive is attached. I tried many combination but to no avail and right now don't know how to make it work.
Are you talking here about the code you've posted in the same post of you? Because there is no measures for Drive4. Also not sure what .inc file are you talking about, because nor a such file is included in the code (well, in fact there are no included files at all).
So if you want to hide the meter when there none of the Drive1 - Drive4 isn't connected, you have to add at least one measure to check the total capacity of Drive4 as well. Add it:

Code: Select all

[MeasureTotalDrive4]
Measure=FreeDiskSpace
Drive=#Drive4#
Total=1
IgnoreRemovable=0
DiskQuota=1
UpdateDivider=2
If you want to hide meter whenever there are no connected drives and show it when there is at least one connected, add the following measure as well:

Code: Select all

[MeasureTotalDrive]
Measure=Calc
Formula=( MeasureTotalDrive1 + MeasureTotalDrive2 + MeasureTotalDrive3 + MeasureTotalDrive4 )
IfCondition=(#CURRENTSECTION#=0)
IfTrueAction=[!HideMeter "MeterStyleTransfer"][!Redraw]
IfFalseAction=[!ShowMeter "MeterStyleTransfer"][!Redraw]
Note that Drive1 is C:, which always is connected, usually being the system drive. So, with the measure above, the [ TRANSFERS ] string is always shown, never hidden. If you want to check only the removable drives (what supposing the E:, F: and G: drives are), remove the MeasureTotalDrive1 from the formula of the above [MeasureTotalDrive] measure: Formula=( MeasureTotalDrive2 + MeasureTotalDrive3 + MeasureTotalDrive4 ).