It is currently March 28th, 2024, 9:11 pm

Hiding an image when a drive is disconnected

Get help with creating, editing & fixing problems with skins
User avatar
sl23
Posts: 1140
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Hiding an image when a drive is disconnected

Post by sl23 »

I have a skin which shows USB drives when they are connected and hides them when disconnected.
I wanted to add a shortcut to E:/SyMenu that only displays when the drive is connected. But no matter what options I try, I can't get it to change the image's hidden status when the drive is inserted or removed.

I can hide or show the image but it doesn't work dynamically. I can show/hide the image when hovered over the skin, but it just refuses to work with drive connection. Can someone please help?

I tried separate meters to show/hide the image and also tried adding it to the E: show/hide IfCondition commend. Nothing seems to work!

Here's the code for the button:
========================================
; E:SYMENU
========================================
[sSyMenu]
Hidden=1
;Group=Hover
-UpdateDivider=-1

[SyMenu]
Meter=Image
MeterStyle=sSyMenu
ImageName=#@#Launchers\SyMenu.png
LeftMouseUpAction=["#ESy#"]
ToolTipText="E: SyMenu"
;IfCondition=mETotal = 0
;IfTrueAction=[!SetOption "sSyMenu" Hidden "1"] [!UpdateMeter *] [!Redraw]
;IfFalseAction=[!SetOption "sSyMenu" Hidden ""] [!UpdateMeter *] [!Redraw]
DynamicVariables=1
X=15
Y=25R
W=35
H=35
Here's the code for E drive:
========================================
; DISK - E:/
========================================
[sE]
Group=Disk-E

[mELabel]
Measure=FreeDiskSpace
Drive=E:
IgnoreRemovable=0
UpdateDivider=#UD2#
Label=1

[mEFree]
Measure=FreeDiskSpace
Drive=E:
IgnoreRemovable=0
UpdateDivider=#UD2#
Substitute=".0":""

[mETotal]
Measure=FreeDiskSpace
Drive=E:
Total=1
IgnoreRemovable=0
UpdateDivider=#UD2#
Substitute=".0":""
IfCondition=mETotal = 0
IfTrueAction=[!SetOptionGroup "Disk-E" Y "0R"] [!HideMeterGroup "Disk-E"][!SetOption "sSyMenu" Hidden "1"] [!UpdateMeter *] [!Redraw]
IfFalseAction=[!SetOptionGroup "Disk-E" Y ""] [!ShowMeterGroup "Disk-E"][!SetOption "sSyMenu" Hidden "0"] [!UpdateMeter *] [!Redraw]
DynamicVariables=1

[ELabel]
Meter=String
MeterStyle=sAllText | sDriveLabel | sHighlight | sE
MeasureName=mEUsed
MeasureName2=mETotal
Text="E:/ %1 %"
LeftMouseUpAction=["#CE#" "E:\"]
MiddleMouseUpAction=["#@#\Addons\USBDiskEjector\USB_Disk_Eject.exe """/SHOWEJECT /REMOVELETTER E""""]
ToolTipTitle="E:/ [mELabel]"

[EFree]
Meter=String
MeterStyle=sAllText | sDriveValue | sE
MeasureName=mEFree

[mEUsed]
Measure=FreeDiskSpace
Drive=E:
IgnoreRemovable=0
UpdateDivider=#UD2#
InvertMeasure=1

[EBar]
Meter=Bar
MeterStyle=sBar | sE
MeasureName=mEUsed
As this is part of a much larger complex skin, there may be something elsewhere that could be causing the issue. I don't think that's the case as it all works when I just want hover the skin to show/hide the image, irrespective of there being a connected drive.

Thank you for your help.

EDIT: I had another idea. I used the Group=Disk-E on the [sSyMenu] section and it worked! Well, this part did, but it screwed up the positioning of everything below it in the code!!! It all gets set to the top of the skin now, ignoring any X/Y info. Any ideas?
Last edited by sl23 on August 16th, 2019, 4:20 pm, edited 1 time in total.
- MuLab -
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Hiding an image when a drive is disconnected

Post by balala »

sl23 wrote: August 6th, 2019, 11:54 pm EDIT: I had another idea. I used the Group=Disk-E on the [sSyMenu] section and it worked! Well, this part did, but it screwed up the positioning of everything below it in the code!!! It all gets set to the top of the skin now, ignoring any X/Y info. Any ideas?
No, the Y positions of the meters belonging to the Disk-E group are not ignored, but you are changing their vertical position, through the IfTrueAction / IfFalseAction options of the [mETotal] measure. If the drive is connected (in which case the IfFalseAction is executed), there is nothing set to the position: [!SetOptionGroup "Disk-E" Y ""], the value which has to be set being left empty (Y option of the group). In this case those meters are set to Y=0, which means exactly the top of the skin. When you disconnect the drive, the vertical position of the meters are set to Y=0R, through the IfTrueAction option, but in this case the meters are hidden, so you can't see them.
Probably you'll have to set a position into the first !SetOptionGroup bang of the IfFalseAction option of the [mETotal] measure as well.
User avatar
sl23
Posts: 1140
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Hiding an image when a drive is disconnected

Post by sl23 »

Thanks for your reply balala. :thumbup:

If I remember correctly, when setting [!SetOptionGroup "Disk-E" Y ""] empty, so no Y position is entered, this tells Rainmeter to revert to using the meters original parameter?

Otherwise it wouldn't work at all, would it?

The way I see it, is that as this is hiding a group, setting this parameter would set everything in that group to the designated Y position. This wouldn't work as text is shown above a bar. Am I wrong in thinking that?

This code was originally given to me by jsmorley, so I haven't altered it at all. It was designed to display Drive info if a drive is connected. If several drives were connected and one removed it hides the disconnected one(s) and moves the info in the meter's below it up so as not to leave blank space between the displayed meter's.

Thanks.
- MuLab -
User avatar
sl23
Posts: 1140
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Hiding an image when a drive is disconnected

Post by sl23 »

I just can't understand why the code below isn't working!!! What am I doing wrong?
(The section [SyMenuText] is just for testing and will be cut eventually)
========================================
; E:SYMENU
========================================

[SyMenu]
Meter=Image
ImageName=#@#Launchers\SyMenu.png
LeftMouseUpAction=["#ESy#"]
ToolTipText="E: SyMenu"
IfCondition=mETotal = 0
IfTrueAction=[!SetOption "SyMenu" Hidden "1"] [!UpdateMeter *] [!Redraw]
IfFalseAction=[!SetOption "SyMenu" Hidden "0"] [!UpdateMeter *] [!Redraw]
DynamicVariables=1
Hidden=1
X=15
Y=25R
W=35
H=35

[SyMenuText]
Meter=String
FontColor=255,0,0
IfCondition=mETotal=0
IfTrueAction=[!ShowMeter "SyMenuText"] [!UpdateMeter *] [!Redraw]
IfFalseAction=[!HideMeter "SyMenuText"] [!UpdateMeter *] [!Redraw]
LeftMouseUpAction=["#ESy#"]
Text=SyMenu
X=15
Y=r
It monitors the value of mETotal=0, ie the Total capacity of E drive, if that is zero then it hides the meter's, yes?
What I find strange is that the same code is used to monitor whether E drive is connected, and that works fine! :? :confused:
So why doesn't it work for the image?
- MuLab -
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Hiding an image when a drive is disconnected

Post by balala »

sl23 wrote: August 7th, 2019, 12:08 pm If I remember correctly, when setting [!SetOptionGroup "Disk-E" Y ""] empty, so no Y position is entered, this tells Rainmeter to revert to using the meters original parameter?
No, it tells to use 0 as the value of the set parameter (in this case the vertical position of the meter), because if you set it empty, there is no value, so the default value is used. And this is 0.
But there is a simple method to check what's going on: add certain value instead of setting empty the parameter and check if it set correctly when the meter is shown.
sl23 wrote: August 7th, 2019, 12:08 pm Otherwise it wouldn't work at all, would it?
Why wouldn't it?
sl23 wrote: August 7th, 2019, 12:08 pm The way I see it, is that as this is hiding a group, setting this parameter would set everything in that group to the designated Y position. This wouldn't work as text is shown above a bar. Am I wrong in thinking that?
Don't know, but it worth a try, probably.
sl23 wrote: August 7th, 2019, 12:08 pm This code was originally given to me by jsmorley, so I haven't altered it at all. It was designed to display Drive info if a drive is connected. If several drives were connected and one removed it hides the disconnected one(s) and moves the info in the meter's below it up so as not to leave blank space between the displayed meter's.
Finally I'm not sure why you have to set the Y parameter of those meters. If you set them not through !SetOption bangs, but directly on the meters to Y=0R, if any of those meters are hidden, the next one takes its place. No need to set its position.

Finally give it a try as I described above, setting a not empty value for the Y parameter and check if it does work. If you can't get it to properly work, please pack the whole config you have and upload it, to can check.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Hiding an image when a drive is disconnected

Post by balala »

sl23 wrote: August 7th, 2019, 1:44 pm I just can't understand why the code below isn't working!!! What am I doing wrong?
Well, what are you doing wrong is that IfConditions are not valid on meters. They can and must be used ONLY on measures. Due to this, none of the posted two IfConditions aren't working, they do nothing. Take care of this.
User avatar
sl23
Posts: 1140
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Hiding an image when a drive is disconnected

Post by sl23 »

balala wrote: August 7th, 2019, 3:44 pm No, it tells to use 0 as the value of the set parameter (in this case the vertical position of the meter), because if you set it empty, there is no value, so the default value is used. And this is 0.
But there is a simple method to check what's going on: add certain value instead of setting empty the parameter and check if it set correctly when the meter is shown.

Why wouldn't it?
Well, looking at my skin, this code for drives being from jsmorley, when the drive is disconnected the Y=0R in order to move the below meters upwards on the skin so as not to leave a gap. Whereas if the Y="" means 0 there would be a problem as it would simply place everything at the top of the skin, which is not the case. So now, I'm even more confused!!! :rofl:

Bare in mind that this works WITHOUT the image attached to this group. As soon as you join the image to the group using Y=0R/Y="" then it screws it all up. So effectively, adding this image meter to the Disk-E group breaks the previously working code.

But... thanks for your help and for pointing out my mistake of using IfCondition in a meter! That must be the issue so I'll look at that and get bk to let you know the result.

Thank you so much for your help :D :thumbup:
- MuLab -
User avatar
sl23
Posts: 1140
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Hiding an image when a drive is disconnected

Post by sl23 »

OHHH MY GOD! How easy was that! :rofl:

I simply added the code to the IfCondition of the mETotal section:
[SyMenu]
Meter=Image
ImageName=#@#Launchers\SyMenu.png
LeftMouseUpAction=["#ESy#"]
ToolTipText="E: SyMenu"
X=15
Y=25R
W=35
H=35

[mETotal]
Measure=FreeDiskSpace
Drive=E:
Total=1
IgnoreRemovable=0
UpdateDivider=#UD2#
Substitute=".0":""
IfCondition=mETotal = 0
IfTrueAction=[!SetOptionGroup "Disk-E" Y "0R"] [!HideMeter "SyMenu"] [!HideMeterGroup "Disk-E"] [!UpdateMeter *] [!Redraw]
IfFalseAction=[!SetOptionGroup "Disk-E" Y ""] [!ShowMeter "SyMenu"] [!ShowMeterGroup "Disk-E"] [!UpdateMeter *] [!Redraw]
DynamicVariables=1
- MuLab -
User avatar
sl23
Posts: 1140
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Hiding an image when a drive is disconnected

Post by sl23 »

I don't suppose as an extension of this, that it's possible to have this shortcut work even if the drive letter changes?
Sort of like the autorun.inf can show an icon for a drive.
But instead this one would be clickable on a skin and open SyMenu.

Would be good but at present not an issue if it can't.

Thanks :D
- MuLab -
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Hiding an image when a drive is disconnected

Post by balala »

sl23 wrote: August 7th, 2019, 4:43 pm I simply added the code to the IfCondition of the mETotal section:
Ok, good this way, too.
Did you get it working now as expected?