It is currently September 17th, 2021, 12:25 pm

Eject USB

Help with creating, editing & fixing problems with skins
User avatar
balala
Rainmeter Sage
Posts: 13198
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Eject USB

Post by balala »

Sam12345 wrote: March 22nd, 2021, 9:42 pm I thought it felt snappier, but I told my self it was my imagination :?
Let's show you what a !UpdateMeter bang does. See the next code:

Code: Select all

[Rainmeter]
Update=3000

[Variables]
Col=0

[MeterUpdate]
Meter=Image
SolidColor=255,(240*#Col#),0
X=0
Y=0
W=80
H=50
DynamicVariables=1
LeftMouseUpAction=[!SetVariable Col "(1-#Col#)"][!UpdateMeter "MeterUpdate"][!Redraw]
As you can see the Update of this skin is set to Update=3000 (no, that's not a mistake!), which means one update per three seconds. The skin shows a red rectangle and when you click it, its color changes to yellow, then back to red.
With the above LeftMouseUpAction option of the [MeterUpdate] meter, you get the color changing instantly when you click the meter. But if you remove either the [!UpdateMeter "MeterUpdate"] bang or both bangs ([!UpdateMeter "MeterUpdate"][!Redraw]), you get the color changing only on next update cycle of the skin (so the change takes up to three seconds). See that doesn't matter too much if the [!Redraw] bang is there or not, if you don't update the meter with the [!UpdateMeter "MeterUpdate"] bang, the change can be seen only when the meter updates on the normal update cycle of the skin. This is normal, because if the meter is not updated (by the !UpdateMeter bang), the redrawn of the skin (done with the !Redraw bang) doesn't matter, the meter keeps its previous state. The !UpdateMeter bang, along with the !Redraw bang fix this, getting an immediate update of the meter and redrawn of the skin, without having to wait for the next normal update cycle.
Sam12345 wrote: March 22nd, 2021, 9:42 pm For example, I want to create an image for the USB ejector as the one now isn't good. I could just download a photo of the internet and resize it, but I want to make one that matches the rest of the skin.
Yep, I had this kind of approach on all buttons of my Mirage suite (yep, this again is a self-promotion). For instance the eject button looks this way in those skins:
Eject.png
This is done not using an image, but a font.
To use this symbol, first you have to download the appropriate font (in this case Guifx v2 Transports.ttf, available for example here). Download it and move the file to the @Resources\Fonts folder of your skin (if the Fonts folder doesn't exist, just create it).
Then I used the following meter to create the appropriate symbol:

Code: Select all

[MeterEjectLabel]
Meter=String
X=30
Y=25
W=46
H=26
FontSize=14
StringAlign=CENTERCENTER
FontColor=220,220,220
FontEffectColor=0,0,0
SolidColor=0,0,0,100
StringEffect=Shadow
FontFace=Guifx v2 Transports
StringStyle=BOLD
AntiAlias=1
Text='
LeftMouseUpAction=[!CommandMeasure "MeasureUDisk" "RemoveDrive"]
Obviously you can change the settings, this is just an example of how can you create a this way drawn button.
Sam12345 wrote: March 22nd, 2021, 9:42 pm O.O I don't remember changing that, I must have done it by mistake. Thanks for pointing it out :thumbup:
Don't worry, happens to all of us, from time to time.
You do not have the required permissions to view the files attached to this post.
User avatar
Sam12345
Posts: 80
Joined: February 27th, 2021, 9:41 pm
Location: London

Re: Eject USB

Post by Sam12345 »

balala wrote: March 23rd, 2021, 4:55 pm Let's show you what a !UpdateMeter bang does.
Cool. Does it update the whole skin or just that meter? And if it updates the whole skin, could a skin be set to update=90000000 and then update only if needed (ie. in a dock that doesn't need to show any info) by hovering the mouse on it? (making it less resource hungry) :sly:
balala wrote: March 23rd, 2021, 4:55 pm This is done not using an image, but a font.
So I suppose that some things like ImageTint wouldn't work?
Insert inspirational quote here
User avatar
balala
Rainmeter Sage
Posts: 13198
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Eject USB

Post by balala »

Sam12345 wrote: March 24th, 2021, 2:30 pm Does it update the whole skin or just that meter? And if it updates the whole skin, could a skin be set to update=90000000 and then update only if needed (ie. in a dock that doesn't need to show any info) by hovering the mouse on it? (making it less resource hungry) :sly:
[!UpdateMeter "MeterUpdate"] updates only the [MeterUpdate] meter, [!UpdateMeasure "MeasureUpdate"] updates the [MeasureUpdate] measure. [!Update] on the other hand updates the whole skin.
update=90000000 can be set, but it means one update on each 90,000 second and this is equal to 25 hours, so more than a day. It can be done, however instead I better would set it to Update=-1, which means no update except the very first moment when you refresh / load the skin. Such in a case, you have to take care to always manually update either the skin or at least the appropriate measures and meters, whenever is it needed.
Sam12345 wrote: March 24th, 2021, 2:30 pm So I suppose that some things like ImageTint wouldn't work?
ImageTint doesn't work on String meters, it does work only on Image meters (or at least on meters showing an image).
User avatar
Sam12345
Posts: 80
Joined: February 27th, 2021, 9:41 pm
Location: London

Re: Eject USB

Post by Sam12345 »

balala wrote: March 24th, 2021, 3:24 pm which means no update
This prompted a question - What happens if I remove the Update=? I removed for a skin, and I couldn't see a difference - It continued updating on around the same rate as before (unlike if I set Update=100000)
I have another question on this skin :oops: :)
I wanted a field showing my name/username. However, my username isn't my name (long story), so I just used a text string. However, I now want to do it properly and use IfMatch to show my name instead of my username, or otherwise to show the name.
This is the code for that meter:

Code: Select all

[MeterUserName]
Meter=STRING
MeterStyle=styleText1
MeasureName=MeasureUser
IfMatch=MeterUserName="spost"
IfMatchAction=[!SetOption MeterUserName Text "Sam P"]
IfNotMatchAction=[!SetOption MeterUserName Text "#MeterUserName#"]
X=0r
Y=4
UpdateDivider=-1
AntiAlias=1
IfMatchMode=1
However, it just shows my username (spost), rather than replacing it with my name (Sam P). :confused:
Insert inspirational quote here
User avatar
balala
Rainmeter Sage
Posts: 13198
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Eject USB

Post by balala »

Sam12345 wrote: March 24th, 2021, 8:00 pm This prompted a question - What happens if I remove the Update=? I removed for a skin, and I couldn't see a difference - It continued updating on around the same rate as before (unlike if I set Update=100000)
If you remove the Update option, Rainmeter applies the default Update, which is Update=1000 (milliseconds). This is the most comon case, in majority of skins and applies to ALL, not explicitely set options, on ALL sections (general sections, like [Rainmeter], as well as on measures and meters). This is why all default values are extremely important and are shown in the online manual.
As you probably figured out, Update=100000, means one update per 100,000 milliseconds = 100 seconds, so more than one and a half minute.
Sam12345 wrote: March 24th, 2021, 8:00 pm I wanted a field showing my name/username. However, my username isn't my name (long story), so I just used a text string. However, I now want to do it properly and use IfMatch to show my name instead of my username, or otherwise to show the name.
This is the code for that meter:

Code: Select all

[MeterUserName]
Meter=STRING
MeterStyle=styleText1
MeasureName=MeasureUser
IfMatch=MeterUserName="spost"
IfMatchAction=[!SetOption MeterUserName Text "Sam P"]
IfNotMatchAction=[!SetOption MeterUserName Text "#MeterUserName#"]
X=0r
Y=4
UpdateDivider=-1
AntiAlias=1
IfMatchMode=1
However, it just shows my username (spost), rather than replacing it with my name (Sam P). :confused:
You can't use IfMatch on meters. IfMatch (and all conditional statements, like IfCondition or the older IfActions - IfBelow, IfEqual, IfAbove) are useable ONLY on measures, that's why the above IfMatch doesn't work.
User avatar
balala
Rainmeter Sage
Posts: 13198
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Eject USB

Post by balala »

Sam12345 wrote: March 24th, 2021, 8:00 pm This is the code for that meter:

Code: Select all

[MeterUserName]
Meter=STRING
MeterStyle=styleText1
MeasureName=MeasureUser
IfMatch=MeterUserName="spost"
IfMatchAction=[!SetOption MeterUserName Text "Sam P"]
IfNotMatchAction=[!SetOption MeterUserName Text "#MeterUserName#"]
X=0r
Y=4
UpdateDivider=-1
AntiAlias=1
IfMatchMode=1
However, it just shows my username (spost), rather than replacing it with my name (Sam P). :confused:
Additional note: as said, the IfMatch options can't be applied on meter, so you have to move the above IfMatch, IfMatchAction, IfNotMatchAction and IfMatchMode options to the [MeasureUser] measure. But the IfMatch is used a little bit incorrectly. You have to use under it only a string. The option checks if this string match the value returned by the measure where is it used and executes the IfMatchAction if it does and the IfNotMatchAction otherwise. So for instance if, as said above, you move the IfMatch (and its subsequent) options to the [MeasureUser] measure, the IfMatch option should be only IfMatch=spost and it checks if the value of the measure it is used in (in this case [MeasureUser], because there have you moved the options) match the posted string (spost in this case), executing the bang of either the IfMatchAction or the IfNotMatchAction, accordingly.
User avatar
Sam12345
Posts: 80
Joined: February 27th, 2021, 9:41 pm
Location: London

Re: Eject USB

Post by Sam12345 »

balala wrote: March 24th, 2021, 8:33 pm You can't use IfMatch on meters.
So I moved it to measures and created a mix between it and meters and it works :YESSS:
balala wrote: March 24th, 2021, 8:45 pm Additional note
I was looking on the manuel and saw I didn't need it so i removed when moving it to the meters :great:
Insert inspirational quote here
User avatar
balala
Rainmeter Sage
Posts: 13198
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Eject USB

Post by balala »

Sam12345 wrote: March 24th, 2021, 8:54 pm So I moved it to measures and created a mix between it and meters and it works :YESSS:

I was looking on the manuel and saw I didn't need it so i removed when moving it to the meters :great:
Great!
User avatar
Sam12345
Posts: 80
Joined: February 27th, 2021, 9:41 pm
Location: London

Re: Eject USB

Post by Sam12345 »

balala wrote: March 24th, 2021, 9:17 pm Great!
And then... It stopped working. :-( I was changing the text color for when the mouse hovers over it, and after I done that, it went back to "spost", and nothing I can to changes that. I removed my new addition so its back to where it started, and still.

Code: Select all

[MeasureUser]
Measure=Plugin
Plugin=Plugins\SysInfo.dll
SysInfoType=USER_NAME
IfMatch="Spost"
IfMatchAction=[!SetOption MeterUserName Text "Sam P"]
UpdateDivider=-1
IfMatchMode=1
;-------------------------------------------------------------
;-------------------------------------------------------------
[MeterUserName]
Meter=STRING
MeterStyle=styleText1
MeasureName=MeasureUser
X=0r
Y=4
AntiAlias=1
I cant see anyhthing wrong (besdies its a bit mixed up between the measure and the meatre, but it worked before).
This is what I added in:
MouseOverAction=[!SetOption MeterUserName FontColor 255,255,255,100][!UpdateMeter "MeterUserName"][!Redraw]
MouseLeaveAction=[!SetOption MeterUserName FontColor 255,255,255][!UpdateMeter "MeterUserName"][!Redraw]

:(
Insert inspirational quote here
User avatar
balala
Rainmeter Sage
Posts: 13198
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Eject USB

Post by balala »

Sam12345 wrote: March 24th, 2021, 9:30 pm And then... It stopped working. :-( I was changing the text color for when the mouse hovers over it, and after I done that, it went back to "spost", and nothing I can to changes that. I removed my new addition so its back to where it started, and still.
Remove the UpdateDivider=-1 option from the [MeasureUser] measure, because if this option is there, the measure is never updated.
Additionally, where have you added the MouseOverAction and MeasureLeaveAction options?