It is currently March 28th, 2024, 6:08 pm

in need for guidance...

Discuss the use of Lua in Script measures.
Post Reply
tgra
Posts: 2
Joined: February 21st, 2018, 12:47 pm

in need for guidance...

Post by tgra »

Hi all,

I'm completely clueless about LUA scripting (not great at coding anything in general) , I tried to read about it but this is far beyond my reach...

Basically I have a program I use all the time which involves launching "cmd" and typing in several commands. I already created a bat file to avoid retyping the command each time (so I basically open "cmd" then drag the bat file in, press enter and voila!

I wondered if there was a nifty way to have all this actions simplified by lua scripting just so I simply have to click my dedicated rainmeter app to execute all that?

I would really appreciate a bit of help on this one... I'll owe you forever! :17good

Ps: if anyone could be bothered explaining me how to add "open the "Z:\ drive" at the end of the batch action of my bat file, that would be even more wonderful!!
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: in need for guidance...

Post by jsmorley »

I don't actually think Lua is going to offer much here. Lua can execute shell commands certainly, but they would need to be done one at a time, and each would pop up a cmd.exe console window for a second while they execute.

I think your best bet is one of two ways:

1) If you don't mind seeing, or even want to see, the console window while the commands execute, you can just run your .bat file directly from any "action" in Rainmeter:

LeftMouseUpAction=["#@#MyBatFiles\BatchOfCommands.bat"]

2) If you would rather that the batch file be executed "silently", without the console window, then you can use the RunCommand plugin:

Code: Select all

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

[MeasureRunBat]
Measure=Plugin
Plugin=RunCommand
Parameter=""#@#\MyBatFiles\BatchOfCommands.bat""
OutputType=ANSI
State=Hide

[MeterRun]
Meter=String
FontSize=12
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text=Run BatchOfCommmands.bat
LeftMouseUpAction=[!CommandMeasure MeasureRunBat "Run"]
https://docs.rainmeter.net/manual/plugins/runcommand/

The same would be true if you wanted to do it as an old-school .bat batch file, a .ps1 powershell script, or a .vbs visual basic script. I think all the cool kids are using powershell these days...

Code: Select all

[MeasureRunPS1]
Plugin=RunCommand
Program=PowerShell
Parameter=-NoProfile -ExecutionPolicy Bypass -Command "& '#@#\MyScriptFiles\ScriptOfCommands.ps1'"
OutputType=ANSI
State=Hide
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: in need for guidance...

Post by jsmorley »

tgra wrote: Ps: if anyone could be bothered explaining me how to add "open the "Z:\ drive" at the end of the batch action of my bat file, that would be even more wonderful!!
In the .bat batch file, just add:

explorer "Z:\"
tgra
Posts: 2
Joined: February 21st, 2018, 12:47 pm

Re: in need for guidance...

Post by tgra »

Hi Jsmorley,

Thank you so much for taking the time to help me out... Unfortunately I'm still not there just yet - your explanation seems crystal clear, I'm just a bit slow!

Basically I'm facing two issues here:
PROBLEM #1
The "silent" option would be perfect for me although I can't figure out how to apply this to my batch file...
in this case, my bat file is named "ML.bat" and it's located in "C:\mlvfs" .. what do I need to change to that code in order to get it working?

PROBLEM #2

my batch is not working how I would like it to...
The actual program (mlvfs.exe) is located in the same folder as the .bat file ("C:\mlvfs\mlvfs.exe") so I created a .bat on my desktop, had a little play around and came up with this:

Code: Select all

cd..
cd..
cd..
cd mlvfs
mlvfs.exe Z:\  --mlv_dir=G:\DCIM\100EOS5D
PING localhost -n 6 >NUL
explorer "Z:\"
I have never used PING so the problem must definitely be coming from there. The

Code: Select all

PING localhost -n 6 >NUL
was an attempt to make cmd wait 5 seconds before trying to open "Z:\" as the program MLVFS create this artificial "Z:\" mount but it takes a couple of secs before achieving so...
How can I fix this one?


again, sorry for my ignorance...
MikeG621
Posts: 87
Joined: March 18th, 2013, 1:59 pm

Re: in need for guidance...

Post by MikeG621 »

For the wait issue, instead of the ping use timeout /t 5, where "5" is the number of seconds.
User avatar
CyberTheWorm
Posts: 860
Joined: August 22nd, 2016, 11:32 pm
Location: Surrey, B.C., Canada

Re: in need for guidance...

Post by CyberTheWorm »

You don't need 4 lines at the top also

Code: Select all

cd..
cd..
cd..
cd mlvfs
mlvfs.exe Z:\  --mlv_dir=G:\DCIM\100EOS5D
PING localhost -n 6 >NUL
explorer "Z:\"
Can become using MikeG suggestion

Code: Select all

cd\ mlvfs
mlvfs.exe Z:\  --mlv_dir=G:\DCIM\100EOS5D
timeout /t 6
explorer "Z:\"
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: in need for guidance...

Post by jsmorley »

CyberTheWorm wrote:You don't need 4 lines at the top also

Code: Select all

cd..
cd..
cd..
cd mlvfs
mlvfs.exe Z:\  --mlv_dir=G:\DCIM\100EOS5D
PING localhost -n 6 >NUL
explorer "Z:\"
Can become using MikeG suggestion

Code: Select all

cd\ mlvfs
mlvfs.exe Z:\  --mlv_dir=G:\DCIM\100EOS5D
timeout /t 6
explorer "Z:\"
This:

cd\ mlvfs

is actually a syntax error. It needs to be:

cd \mlvfs

The cd command will also accept it without the space after the command like:

cd\mlvfs

but I recommend against getting in that habit, most commands won't...


That's assuming that mlvfs is at the root level of the current drive... If the actual intent is to move up three relative levels and then down into mlvfs, it would be:

cd ..\..\..\mlvfs
Post Reply