Anatomy of a Plugin


Rainmeter's functionality can be expanded with the use of external plugins. Anyone with knowledge of C++ or C# can make a plugin for Rainmeter.

Exported functions

Rainmeter plugins have a general list of functions that they must export and a few optional ones for additional functionality.

Initialize

Called before anything on measures first load.
Initialize your object you want to store in the data pointer here, as well as any other setup your plugin will need to do. You should also store the measure refernce here if you are going to make use of it outside Initialize or Reload.

Reload

Called right after Initialize and on every update cycle of the measure if DynamicVariables=1.
Read any options from the measure in here and then doing any remaining setup that your plugin needed to do based on them.

Update

Called on every update cycle of the measure.
Return the value you want to use as the number value of the measure here. You should do anything that requires being run regularly here

Finalize

Called whenever a measure is unloaded.
Deallocate anything here to prevent memory leaks. Note that on skin reload finalize and initalize will both be called right after each other.

GetString (Optional)

Called as the string value of the measure is used in any meters or measures.
Return the value you want to use as the string value of the measure here. You should do absolutely no processing here as it is possible to have this called multiple times an update. Instead calculate any values in update and just return them here.

ExecuteBang (Optional)

Called whenever a !CommandMeasure bang is used.
Incredibly useful for interacting with your plugin. Media playback plugins are a good example of using this, so then a skin could have a button to pause the music on command.

SectionVariables (Optional)

Called whenever a section variables is used ex. [pluginMeasure:func(arg1, arg2)].
While similar to ExecuteBang this has the added nicety of being able to return a value. Note that Rainmeter prevents these from being called before Initialization so data will be setup.