It is currently January 22nd, 2022, 6:22 am

How to put this code that can switch skin color according to day and night time into another clock?

Help with creating, editing & fixing problems with skins
User avatar
Pyuahowaito
Posts: 7
Joined: January 3rd, 2022, 2:44 pm

How to put this code that can switch skin color according to day and night time into another clock?

Post by Pyuahowaito »

I tried many times without any effect (another clock is in the attachment)

Code: Select all

IfCondition=(MeasureTime >= 6) && (MeasureTime < 12)
IfTrueAction=[!SetVariable TextColor "255,255,255,255"]
IfCondition2=(MeasureTime >= 12) && (MeasureTime < 18)
IfTrueAction2=[!SetVariable TextColor "255,255,255,255"]
IfCondition3=(MeasureTime >= 18) && (MeasureTime < 22)
IfTrueAction3=[!SetVariable TextColor "414141"]
IfCondition4=(MeasureTime >= 22) || (MeasureTime < 6)
IfTrueAction4=[!SetVariable TextColor "414141"]
You do not have the required permissions to view the files attached to this post.
Last edited by Pyuahowaito on January 12th, 2022, 9:46 pm, edited 2 times in total.
User avatar
balala
Rainmeter Sage
Posts: 13719
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: How to put this code that can switch skin color according to day and night time into another clock?

Post by balala »

Pyuahowaito wrote: January 12th, 2022, 9:09 pm I tried many times without any effect (another clock is in the attachment)
Add a DynamicVariables=1 option to the [MeterTime] meter, because it uses the dynamically set TextColor variable.
User avatar
Pyuahowaito
Posts: 7
Joined: January 3rd, 2022, 2:44 pm

Re: How to put this code that can switch skin color according to day and night time into another clock?

Post by Pyuahowaito »

You may have misunderstood me, I want to apply this code to the clock in the attachment, and let it change the corresponding skin color according to the time of day and night. I don’t know how to do it. I don’t see the word [MeterTime] in the clock of the attachment. You can Download and take a look.

Code: Select all

IfCondition=(MeasureTime >= 6) && (MeasureTime < 12)
IfTrueAction=[!SetVariable TextColor "255,255,255,255"]
IfCondition2=(MeasureTime >= 12) && (MeasureTime < 18)
IfTrueAction2=[!SetVariable TextColor "255,255,255,255"]
IfCondition3=(MeasureTime >= 18) && (MeasureTime < 22)
IfTrueAction3=[!SetVariable TextColor "414141"]
IfCondition4=(MeasureTime >= 22) || (MeasureTime < 6)
IfTrueAction4=[!SetVariable TextColor "414141"]
Like this the color corresponding to day and night, but I don't know how to make it automatically switch
You do not have the required permissions to view the files attached to this post.
User avatar
balala
Rainmeter Sage
Posts: 13719
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: How to put this code that can switch skin color according to day and night time into another clock?

Post by balala »

Pyuahowaito wrote: January 12th, 2022, 10:53 pm You may have misunderstood me, I want to apply this code to the clock in the attachment, and let it change the corresponding skin color according to the time of day and night. I don’t know how to do it. I don’t see the word [MeterTime] in the clock of the attachment.
You've replaced in meantime the posted code. Then I didn't download the attached skin, just worked with the code. And that one had a meter called [MeterTime]. But doesn't matter.
To do what you want to do, right click the skin, click Edit skin. The code of your skin opens in the default text editor. Add the following measure to the code:

Code: Select all

[MeasureTime]
Measure=Time
Format=%#H
IfCondition=((MeasureTime>=6)&&(MeasureTime<18))
IfTrueAction=[!SetVariable Linecolor "255,255,255,255"][!SetVariable MLinecolor "255,255,255,255"][!SetVariable Hourcolor "255,255,255,255"][!SetVariable Mincolor "255,255,255,255"][!SetVariable Seccolor "255,255,255,255"]
IfFalseAction=[!SetVariable Linecolor "65,65,65,65"][!SetVariable MLinecolor "65,65,65,65"][!SetVariable Hourcolor "65,65,65,65"][!SetVariable Mincolor "65,65,65,65"][!SetVariable Seccolor "65,65,65,65"]
Note here that I shortened a little bit the code of your example, replacing the initial four IfCondition / IfTrueAction options with a single IfCondition and the corresponding IfTrueAction / IfFalseAction. Didn't worth to have all four conditions, because the first two were the same and the last two were again identical.
Please try out the code and let me know if it match your needs.
User avatar
Pyuahowaito
Posts: 7
Joined: January 3rd, 2022, 2:44 pm

Re: How to put this code that can switch skin color according to day and night time into another clock?

Post by Pyuahowaito »

:) It is running stably, and it is worthy of being a professional. It turned out that I only needed to make a little modification on the original basis, but I tossed it for a long time. Thank you for your guidance! I also beautified the code a little, it is more beautiful, thank you and the author of this clock, I can feel the charm of the code more and more now
You do not have the required permissions to view the files attached to this post.
User avatar
balala
Rainmeter Sage
Posts: 13719
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: How to put this code that can switch skin color according to day and night time into another clock?

Post by balala »

Pyuahowaito wrote: January 13th, 2022, 6:46 pm :) It is running stably, and it is worthy of being a professional. It turned out that I only needed to make a little modification on the original basis, but I tossed it for a long time. Thank you for your guidance! I also beautified the code a little, it is more beautiful, thank you and the author of this clock, I can feel the charm of the code more and more now
Glad if you like it. :thumbup:
If you want, you can experiment, changing the colors set through the !SetOption bangs of the IfTrueAction and IFalseAction options, finding shades which are better match your needs.