Rainmeter Workshop: @include

4 min read

Deviation Actions

Rainmeter's avatar
By
Published:
8.5K Views
One of Rainmeter's most useful feature for suite creation is the include statement. This single line allows all the skins across your future suite to share the same exact code, allowing global changes with just the edit of one file. It also cuts down on redundant code.

The most common use of include is global variables. This allows a user (or developer) to customize or change the variables of the suite easily. It also works very well with RainConfigure (or similar program).

But it's more powerful than that. Styles and measures can be used too. Meters can also be used, but they are rendered last, making them on top of everything else. I wouldn't recommend using meters.

Without further ado, sample skin(s)!





Download the .rmskin file to see how everything is set up.  These two very simple skins show how to use multiple include statements and demonstrates using Variables and Styles. include measures aren't used for simplicity of the code.

These text files and skin files are in a folder called AtInclude. Subfolder are CPU and RAM where the respective skins are. include files are in the main directory.

include:

This is the contents of Variables.txt. Obviously, this is just like how variables would be used in any Rainmeter skin. Don't forget to use [Variables].

[Variables]
FONT=Trebuchet MS
SIZE=12
COLOR=255,255,255


@include2:

This is Style.txt. It contains the heart and soul of these two little skins--The Text. Both of these include files could be combined into one.

[Text]
SolidColor=0,0,0,1
StringStyle=Normal
StringAlign=Left
FontColor=#COLOR#
FontSize=#SIZE#
FontFace=#FONT#
AntiAlias=1


SKIN 1: CPU

I'm using DynamicWindowSize because Rainmeter was displaying double digit CPU usage incorrectly and that fixed the problem.

[Rainmeter]
Update=1000
DynamicWindowSize=1


This is how you use multiple include files. Of course you can use @include3, etc.

include=#SKINSPATH#TutorialsAtIncludeStyle.txt
@include2=#SKINSPATH#TutorialsAtIncludeVariables.txt

[MeasureCPU]
Measure=CPU


This used the [Text] style from Style.txt. All the code in the include statements are used as if they are written in the skin's .ini file. So this allows [Text] to use the variables in Variables.txt.

[CpuText]
MeasureName=MeasureCPU
Meter=String
MeterStyle=Text
Text=CPU: %1


SKIN 2: RAM

This is basically identical to the CPU so I won't rehash what's going on. It's just included to demonstrate using the same include statements in multiple skins.

[Rainmeter]
Update=1000

include=#SKINSPATH#TutorialsAtIncludeStyle.txt
@include2=#SKINSPATH#TutorialsAtIncludeVariables.txt

[MeasureRAM]
Measure= PhysicalMemory

[RamText]
MeasureName=MeasureRAM
Meter=String
MeterStyle=Text
Text=RAM: %1
Percentual=1


TIPS and TRICKS

include statements can be included in files are used in include statements. Nested include statements if you will. I've used this and Nircmd to switch visual styles in Seclorum by switching the nested include path. A current skins I'm using will include multiple languages using this method.

I've also used a file to parse a variables file so I could perform calculations on the font colors to create automatic hover colors. Convoluted and unnecessary, yes. Cool, definitely.

PS:  Make suggestions.  Ask questions.  Give me ideas for future workshops.  Please!

Varelse42
© 2010 - 2024 Rainmeter
Comments6
Join the community to add your comment. Already a deviant? Log In
jsmorley's avatar
Very nice tutorial / workshop. Good idea. If you are interested, I would like to also put these workshops up in the Tip and Tricks area of the main Rainmeter documentation. My thinking would be to put up the older one as soon as you put up new one, so it can be have maximum exposure here, and then offered to the additional audience on the main site and kept handy for future reference after a new one is released.

Up to you guys, glad to have this excellent info on the main site if you are interested.