It is currently March 29th, 2024, 1:42 pm

RainFile hindering a Lua Script from working

Discuss the use of Lua in Script measures.
User avatar
Krainz
Posts: 186
Joined: May 27th, 2012, 5:16 am

RainFile hindering a Lua Script from working

Post by Krainz »

Hi, I'm using the ImageCopy script posted by jsmorley here http://rainmeter.net/forum/viewtopic.php?p=106003#p106003 but added RainFile to get the image to be copied.

However, the image is only being copied after I click the meter again. Why is that so?

My code:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[Variables]
@include=#CURRENTPATH#Variables.inc
OutFile=#CURRENTPATH#DownloadFile\TestOutFile.jpg

[MeasureRun]
Measure=Plugin
Plugin=RunCommand
Parameter=copy "#InFile#" "#OutFile#"
DynamicVariables=1

[MeasureScript]
Measure=Script
ScriptFile=#CURRENTPATH#Test.lua
UpdateDivider=-1

[MeterOne]
Meter=Image
W=50
H=50
ImageName=#CURRENTPATH#DownloadFile\TestInFile.jpg
LeftMouseUpAction=["#@#RainFile\RainFile.exe" "File" "Variables" "InFile" "#CURRENTPATH#fetch.inc" "#CURRENTPATH#Image.jpg" "DPNE"][!CommandMeasure MeasureScript "FileCopy()"]

[MeterOne]
Meter=Image
W=50
H=50
X=10R
ImageName=#CURRENTPATH#DownloadFile\TestOutFile.jpg
User avatar
Krainz
Posts: 186
Joined: May 27th, 2012, 5:16 am

Re: RainFile hindering a Lua Script from working

Post by Krainz »

Apparently the [!CommandMeasure MeasureScript "FileCopy()"] part is being executed at the same time that RainFile is executed. I need it to be executed AFTER RainFile is done writing the variable. Any ideas?
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: RainFile hindering a Lua Script from working

Post by balala »

Maybe there is a better solution, but to execute one bang just a few moments after another, you could try to add this variable and measure to your code:

Code: Select all

[Variables]
ExecAfter=1

[Timer]
Measure=Calc
Formula=( Timer + 1 )
Disabled=1
IfCondition=(Timer=#ExecAfter#)
IfTrueAction=[!CommandMeasure MeasureScript "FileCopy()"][!DisableMeasure Timer]
and modify the LeftMouseUpAction on [MeterOne] section:

Code: Select all

LeftMouseUpAction=["#@#RainFile\RainFile.exe" "File" "Variables" "InFile" "#CURRENTPATH#fetch.inc" "#CURRENTPATH#Image.jpg" "DPNE"][!EnableMeasure Timer]
This way when you click to [MeterOne], the RainFile is executed and the Timer measure is enabled (it starts to count). After #ExecAfter# update cycles, the [!CommandMeasure MeasureScript "FileCopy()"] is executed and the Timer measure disabled, so it'll come back to 0.
You have to find the proper value for #ExecAfter# variable, but I think 1 would be a good try.
As I said, I don't know if this is the best method to do the delay. Maybe someone could find a better one?
And just to know, what is this RainFile.exe? Maybe I met it, but I can't remember.