It is currently March 28th, 2024, 10:33 pm

Setting The Contents Of A Plugin Measure To A Variable?

Get help with creating, editing & fixing problems with skins
on1on
Posts: 33
Joined: October 20th, 2010, 12:43 am

Setting The Contents Of A Plugin Measure To A Variable?

Post 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!
User avatar
santa_ryan
Posts: 397
Joined: June 22nd, 2010, 4:11 am

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

Post by santa_ryan »

The only way that i know of doing this is from Lua. It is REALLY easy in lua.
I have three rules when I'm trying to help you.
  • Don't get mad when you don't understand something
  • Be VERY specific with what you ask for.
    The more specific you are, the higher the quality of support you receive.
  • Do not just copy and paste what I put in examples and come back saying it doesn't work.
    It does work, but I purposely left blanks that you need to fill for your specific needs.
on1on
Posts: 33
Joined: October 20th, 2010, 12:43 am

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

Post 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
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

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

Post 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
on1on
Posts: 33
Joined: October 20th, 2010, 12:43 am

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

Post 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
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

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

Post 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"]
on1on
Posts: 33
Joined: October 20th, 2010, 12:43 am

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

Post 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!
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

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

Post 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...