Page 1 of 1

Setting The Contents Of A Plugin Measure To A Variable?

Posted: February 26th, 2011, 9:17 am
by on1on
Is it possible to "extract" the data of a plugin measure and set it as a variable? In particular, I want to do this with a measure using QuotePlugin.dll to get the location of images.

Code: Select all

[mImage]
Measure=Plugin
Plugin=QuotePlugin.dll
PathName=#ImagePath#
Subfolders=1
FileFilter=*.jpg
UpdateDivider=3600

[Image]
Meter=IMAGE
MeasureName=mImage

[ImageLocation]
Meter=STRING
MeasureName=mImage
This code will display both an Image and the location of that Image in the form of a string. Is it possible to take that string and set it as a variable? I have tried using !RainmeterSetVariable to no success, and I believe I read that it isn't possible. I have tried using !RainmeterWriteKeyValue, but don't quite understand the syntax.

Any help is appreciated!

Re: Setting The Contents Of A Plugin Measure To A Variable?

Posted: February 26th, 2011, 11:03 am
by santa_ryan
The only way that i know of doing this is from Lua. It is REALLY easy in lua.

Re: Setting The Contents Of A Plugin Measure To A Variable?

Posted: February 26th, 2011, 4:57 pm
by on1on
santa_ryan wrote:The only way that i know of doing this is from Lua. It is REALLY easy in lua.
REALLY easy, you say? Do you mind demonstrating? I don't know a thing about Lua, unfortunately... but I learn fast from tearing apart other people's code :D

Re: Setting The Contents Of A Plugin Measure To A Variable?

Posted: February 26th, 2011, 5:11 pm
by jsmorley

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1

[Variables]
ImagePath=C:\Users\Jeffrey Morley\Wallpaper
CurrentImage=""

[mImage]
Measure=Plugin
Plugin=QuotePlugin.dll
PathName="#ImagePath#"
Subfolders=1
FileFilter=*.jpg
UpdateDivider=3600

[MeasureSetVar]
Measure=Calc
Formula=Counter %3601
IfEqualValue=0
IfEqualAction=!RainmeterSetVariable CurrentImage "[mImage]"
DynamicVariables=1

[Image]
Meter=IMAGE
MeasureName=mImage
W=300
PreserveAspectRatio=1

[ImageLocation]
Meter=STRING
Y=R
FontSize=11
FontColor=255,255,255,255
MeasureName=mImage

[ImageLocation2]
Meter=STRING
Y=R
FontSize=11
FontColor=255,255,255,255
Text=#CurrentImage#
DynamicVariables=1

Re: Setting The Contents Of A Plugin Measure To A Variable?

Posted: February 26th, 2011, 7:51 pm
by on1on
jsmorley wrote:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1

[Variables]
ImagePath=C:\Users\Jeffrey Morley\Wallpaper
CurrentImage=""

[mImage]
Measure=Plugin
Plugin=QuotePlugin.dll
PathName="#ImagePath#"
Subfolders=1
FileFilter=*.jpg
UpdateDivider=3600

[MeasureSetVar]
Measure=Calc
Formula=Counter %3601
IfEqualValue=0
IfEqualAction=!RainmeterSetVariable CurrentImage "[mImage]"
DynamicVariables=1

[Image]
Meter=IMAGE
MeasureName=mImage
W=300
PreserveAspectRatio=1

[ImageLocation]
Meter=STRING
Y=R
FontSize=11
FontColor=255,255,255,255
MeasureName=mImage

[ImageLocation2]
Meter=STRING
Y=R
FontSize=11
FontColor=255,255,255,255
Text=#CurrentImage#
DynamicVariables=1
This works fantastically! Quick question, though. When the variable CurrentImage is set, where is it actually written? Is there a temporary cache?

For example, If I put CurrentImage="" in Variables.inc and include the file, everything works fine. But if I run a webparser on Variables.inc and RegExp="(?siU)Var5=".*"" it just returns Var5="". (For some reason, RegExp returns everything. Using (.*) makes no difference. I don't understand why, but I'm still learning RegExp =P)

I need to know where it is actually written so that I can parse it and put a substitute on it. And the reason I can't put the substitute on the original measure [mImage] is because then it won't have the proper path to find the picture.

Basically, I need 2 things from [mImage], the original string data "C:\Path\Pictures\folder.jpg"
and a modified substituted data "C:/Path/Pictures/folder.jpg"
which I would use for some other action.

Maybe I'm asking too much... :D

Re: Setting The Contents Of A Plugin Measure To A Variable?

Posted: February 26th, 2011, 8:44 pm
by jsmorley
Variables are not "written" anywhere if they are changed in memory with !RainmeterSetVariable. However, you can change it to add writing it to file as well, so you can then parse for it with WebParser.

IfEqualAction=!Execute [!RainmeterSetVariable CurrentImage "[mImage]"][!RainmeterWriteKeyValue Variables CurrentImage "[mImage]" "#CURRENTPATH#Variables.inc"]

Re: Setting The Contents Of A Plugin Measure To A Variable?

Posted: February 26th, 2011, 9:41 pm
by on1on
jsmorley wrote:Variables are not "written" anywhere if they are changed in memory with !RainmeterSetVariable. However, you can change it to add writing it to file as well, so you can then parse for it with WebParser.

IfEqualAction=!Execute [!RainmeterSetVariable CurrentImage "[mImage]"][!RainmeterWriteKeyValue Variables CurrentImage "[mImage]" "#CURRENTPATH#Variables.inc"]
Brilliant! Works! Why can't I ever get this stuff to work when I do it myself??? I think I either didn't put quotes and brackets around the measurename, or who knows... syntax syntax syntax.

Thank you so much!

Re: Setting The Contents Of A Plugin Measure To A Variable?

Posted: February 26th, 2011, 11:26 pm
by jsmorley
I just make it a practice to always use quotes if I am using a [Measure] or a #Variable#, as you can't always be sure that there won't be spaces in the actual value. One set of quotes too many almost never hurts. One set of quotes too few can have you scratching your head trying to debug...