It is currently April 19th, 2024, 12:53 pm

RunCommand

Share and get help with Plugins and Addons
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: RunCommand 1.0

Post by jsmorley »

Not quite sure. It seems to work for me, although I did change where it is run from, as I am not a fan of putting executables in the same path as my Rainmeter.exe, and I am not running Rainmeter in portable mode.

Code: Select all

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

[MeasureRedShift]
Measure=Plugin
Plugin=RunCommand
Program="#CURRENTPATH#\RedShift.exe"
Parameter="-o -m wingdi -t 6500:4500 -l 41:-73"

[MeterRun]
Meter=Image
W=50
H=50
SolidColor=47,47,47,255
LeftMouseUpAction=!CommandMeasure MeasureRedShift Run
This caused my screen to "warm up" with a red'ish cast when I clicked on the little square meter.

You might want to be sure that Windows isn't complaining about where you have the executable. I don't know what #PROGRAMPATH# is for you, (where you have Rainmeter installed) but Windows can get persnickety about running some apps from some locations with UAC.
User avatar
WandersFar
Posts: 46
Joined: January 25th, 2010, 3:38 pm

Re: RunCommand 1.0

Post by WandersFar »

I have UAC disabled.

Experimented with moving RedShift.exe to the Desktop and changing from a relative to absolute path, as well as doubling the quotes (since it said something about Rainmeter stripping quotes in the readme). Nothing is working.

Do I need to wrap the parameter with quotes? There are multiple switches separated by spaces, so I thought better safe than sorry, but it’s not working either way, so I don’t know…

Why is it bad to have other executables in the same folder as Rainmeter.exe?

The reddish cast is exactly what I’m going for. RedShift is like F.lux, if you’re familiar with that program, only it can be run portably, unlike F.lux. (I try to run only portable software on my computer, hence the portable installation of Rainmeter and RedShift.) It changes the color temperature of your monitor based on time of day—bluer during daylight hours and redder at night. It’s supposed to be better for your eyes.

The non-portable version of RedShift runs constantly, while the command line portable version can be set to just run, adjust the color temp, and self-terminate. Coupled with Rainmeter’s ability to execute programs on a loop based on just about any criteria, it’s a pretty nice solution, the only annoyance was the cmd window, which would pop up during each color adjustment.

That’s why I looked into RunCommand, for the hidden feature. But I can’t get it to work! I tried both the 32-bit and 64-bit versions, (separately, not both at the same time) but it hasn’t made a difference. The original code I posted, that worked, so it doesn’t seem to have to do with where the program’s executable is located, right? It’s just the second version, where I use RunCommand.dll, that’s non-functional.

I read upthread someone else was having trouble with RunCommand in a portable installation? Is the plugin just not compatible with portable Rainmeter?

Thanks for taking the time to help me, I really appreciate it. :)
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: RunCommand 1.0

Post by jsmorley »

I'm kinda stumped as to what you are seeing. It just works for me, using the example skin I posted above. I have Rainmeter installed normally, and put RedShift.exe in the same folder as the skin .ini file.

As to quotes, I would look at this:

Note: Because Rainmeter strips any quotes from the start and end of an option (if both exist), it is important to double quote the Program and Parameter options if needed (ie. Program=""C:\Program Files\Some Program\Something with a space.exe"")

So perhaps try:

Code: Select all

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

[MeasureRedShift]
Measure=Plugin
Plugin=RunCommand
Program=""#CURRENTPATH#\RedShift.exe""
Parameter="-o -m wingdi -t 6500:4500 -l 41:-73"

[MeterRun]
Meter=Image
W=50
H=50
SolidColor=47,47,47,255
LeftMouseUpAction=!CommandMeasure MeasureRedShift Run
I would start by doing some testing with perhaps a redirect to a file on the parameter line, >#CURRENTPATH#SomeFile.txt, to see if the executable is being run at all by Rainmeter, and if so, if it is outputting some error message that you are not seeing. I don't know much (anything really) about the program in question, but somehow you need to find out if Rainmeter is executing it and if it is properly seeing the parameters passed to it.
axolotl_soft
Posts: 27
Joined: October 30th, 2013, 3:50 pm
Location: United States

Re: RunCommand 1.0

Post by axolotl_soft »

I'm trying to use RunCommand in conjunction with nmap & the command prompt to do a UDP port scan on my network and output the list of active nodes to a text file, which Rainmeter will then read and display in a network skin I'm making, along with each node's respective IP address. I'm stumped, though, as the output isn't working at all. The generated file, NMAP.output, contains only a single quotation mark.

I've set my nmap environment variable, and entering "nmap -sP -PU161 192.168.1.1/24" into a command prompt works as it should; after about 10 seconds, it returns a list of active devices, device names, and physical addresses. Here's what I'm working with:

Code: Select all

[MeterPushButton]
Meter                   =   STRING
MeterStyle              =   ItemStyle
Text                    =   PUSH ME
X                       =   140
Y                       =   700
LeftMouseUpAction       =   [!CommandMeasure MeasureNMAP "Run"]

[MeasureNMAP]
Measure                 =   PLUGIN
Plugin                  =   RunCommand
Parameter               =   "nmap -sP -PU161 192.168.1.1/24"
State                   =   hide
OutputFile              =   #@#NMAP.output
OutputType              =   ANSI
FinishAction            =   [!CommandMeasure MeasureNMAPOutput "Update"]
I'm wondering if the delay of 10 seconds is the culprit, and- if so- how to get around it. There's an immediate output of "Starting Nmap 6.47 ( http://nmap.org ) at xxxx-xx-xx xx:xx Eastern Standard Time," however, but this also doesn't surface in the text file.
User avatar
Brian
Developer
Posts: 2679
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: RunCommand 1.0

Post by Brian »

(Sorry for the late reply)

I am not sure what exactly is going on. Nmap seems to work for me using the code below.

Perhaps Webparser is trying to read your output file before RunCommand has closed it (I assume you are using WebParser to filter the results, like I did below). :confused:

-Brian

Code: Select all

[Rainmeter]
Update=1000
AccurateText=1
OnRefreshAction=[!CommandMeasure RunNMAP "Run"]
BackgroundMode=2
SolidColor=0,0,0,215
DynamicWindowSize=1

[RunNMAP]
Measure=Plugin
Plugin=RunCommand
Parameter="nmap -sP -PU161 192.168.1.1/24"
OutputFile="#@#NMAP.output"
OutputType=ANSI
FinishAction=[!EnableMeasure NMAP]

[NMAP]
Measure=Plugin
Plugin=Webparser
Url=file://#@#NMAP.output
RegExp="(?siU)at (.*)\n.*report for (.*)\n.*Host is (.*)\n(.*)\nNMAP done: (.*)$"
Disabled=1

[ScanDate]
Measure=Plugin
Plugin=Webparser
Url=[NMAP]
StringIndex=1

[NetworkName]
Measure=Plugin
Plugin=Webparser
Url=[NMAP]
StringIndex=2

[NetworkStatus]
Measure=Plugin
Plugin=Webparser
Url=[NMAP]
StringIndex=3

[Data]
Measure=Plugin
Plugin=Webparser
Url=[NMAP]
StringIndex=4
Substitute="Nmap scan report for":"Host:", ").":").#CRLF#","MAC":"  MAC","Host":"  Host"

[ScanTime]
Measure=Plugin
Plugin=Webparser
Url=[NMAP]
StringIndex=5

[Style]
FontColor=255,255,255
FontSize=9
FontFace=Lucida Console
X=0
Y=R
Padding=5,1,5,1

[MeterDate]
Meter=String
MeasureName=ScanDate
MeterStyle=Style
Text=Scan Date: %1

[MeterTime]
Meter=String
MeasureName=ScanTime
MeterStyle=Style
Text=Scan Time: %1

[MeterName]
Meter=String
MeasureName=NetworkName
MeterStyle=Style
Text=Name: %1

[MeterStatus]
Meter=String
MeasureName=NetworkStatus
MeterStyle=Style
Text=Status: %1
StringCase=Proper

[MeterData]
Meter=String
MeasureName=Data
MeterStyle=Style
Text=Nodes:#CRLF#%1
Y=5R
DeART.69
Posts: 7
Joined: January 6th, 2015, 2:37 pm

Re: RunCommand 1.0

Post by DeART.69 »

Hello. Help me please with plugin work, I can't make [measureValue] is work.
[Rainmeter]
Update=1000
Background=#@#Background.png
BackgroundMode=3
BackgroundMargins=0,34,0,14

[Metadata]
Version=1.0.0

[Variables]
fontName=Calibri
textSize=8
colorBar=235,170,0,255
colorText=255,255,255,205
;update time
upSecond=10
;minimal voltage of battery
minVoltage=3100

;timer
[measureTimer]
Measure=Calc
Formula=1
UpdateDivider=#upSecond#
OnUpdateAction=[!CommandMeasure measureVoltage Run]
FinishAction=[!SetVariable ding [measureVoltage]]
IfConditionMode=1
IfCondition=(measurePower = 0) && (measureValue = 1)
IfTrueAction=[Play #@#U.wav]

;powershell return voltage of battery
[measureVoltage]
Measure=Plugin
Plugin=RunCommand.dll
Program="powershell.exe"
Parameter="-inputformat none -command "& {([string](Get-WmiObject Win32_Battery | Select-Object DesignVoltage)).Replace('@{DesignVoltage=','').Replace('}','')}""
OutputType=ANSI
;IfAboveValue=#minVoltage#
;IfAboveAction=[!SetVariable ding 0]
;IfBelowValue=#minVoltage#
;IfBelowAction=[!SetVariable ding 1]

;state of charging
[measurePower]
Measure=Plugin
Plugin=PowerPlugin.dll
PowerState=ACLINE

;voltage is low
[measureValue]
Measure=Calc
Formula=[measureVoltage] < #minVoltage# ? 1 : 0

[styleTitle]
StringAlign=CENTER
StringCase=UPPER
StringStyle=BOLD
StringEffect=SHADOW
FontEffectColor=0,0,0,50
FontColor=#colorText#
FontFace=#fontName#
FontSize=10
AntiAlias=1
ClipString=1

[styleLeftText]
StringAlign=LEFT
StringCase=NONE
StringStyle=BOLD
StringEffect=SHADOW
FontEffectColor=0,0,0,20
FontColor=#colorText#
FontFace=#fontName#
FontSize=#textSize#
AntiAlias=1
ClipString=1

[styleRightText]
StringAlign=RIGHT
StringCase=NONE
StringStyle=BOLD
StringEffect=SHADOW
FontEffectColor=0,0,0,20
FontColor=#colorText#
FontFace=#fontName#
FontSize=#textSize#
AntiAlias=1
ClipString=1

[styleSeperator]
SolidColor=255,255,255,15

[meterTitle]
Meter=STRING
MeterStyle=styleTitle
X=100
Y=12
W=190
H=18
Text="система"
LeftMouseUpAction=!Execute ["taskmgr.exe"]

[meterLabelVoltage]
Meter=STRING
MeterStyle=styleLeftText
X=10
Y=100
W=190
H=14
Text="Voltage (mV):"

[meterValueVoltage]
Meter=STRING
MeterStyle=styleRightText
MeasureName=measureVoltage
X=200
Y=0r
W=190
H=14

[meterBarVoltage]
Meter=IMAGE
MeterStyle=styleSeperator
X=10
Y=112
W=190
H=1
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: RunCommand 1.0

Post by jsmorley »

DeART.69 wrote:Hello. Help me please with plugin work, I can't make [measureValue] is work.
Try adding DynamicVariables=1 to that measure.
User avatar
Brian
Developer
Posts: 2679
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: RunCommand 1.0

Post by Brian »

DeART.69 wrote:Hello. Help me please with plugin work, I can't make [measureValue] is work.
jsmorley is correct, you need DynamicVariables=1 on that measure for it to work.

Also, Powershell can be really slow (especially the first time you use it). As an alternative, you can use the WMIC command to get the same results.

Something like this should work:Parameter=wmic Path Win32_Battery Get DesignVoltage (with no Program= option). You might need to substitute the "DesignVoltage" from the results though.

-Brian
DeART.69
Posts: 7
Joined: January 6th, 2015, 2:37 pm

Re: RunCommand 1.0

Post by DeART.69 »

I did it, but code highlighted in red is not working properly.
[measureTimer]
Measure=Calc
Formula=1
UpdateDivider=#upSecond#
OnUpdateAction=[!CommandMeasure measureVoltage Run]
IfConditionMode=1
IfCondition=(measurePower = 0) && (measureValue = 1)
IfTrueAction=[Play #@#U.wav]

[measureVoltage]
Measure=Plugin
Plugin=RunCommand.dll
Parameter="wmic Path Win32_Battery Get DesignVoltage"
Substitute="DesignVoltage ":""
OutputType=ANSI
IfAboveValue=#minVoltage#
IfAboveAction=[!SetVariable ding 0]
IfBelowValue=#minVoltage#
IfBelowAction=[!SetVariable ding 1]


[measurePower]
Measure=Plugin
Plugin=PowerPlugin.dll
PowerState=ACLINE

[measureValue]
Measure=Calc
Formula=measureVoltage < #minVoltage# ? 1 : 0
DynamicVariables=1
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: RunCommand 1.0

Post by jsmorley »

DeART.69 wrote:I did it, but code highlighted in red is not working properly.
[measureTimer]
Measure=Calc
Formula=1
UpdateDivider=#upSecond#
OnUpdateAction=[!CommandMeasure measureVoltage Run]
IfConditionMode=1
IfCondition=(measurePower = 0) && (measureValue = 1)
IfTrueAction=[Play #@#U.wav]

[measureVoltage]
Measure=Plugin
Plugin=RunCommand.dll
Parameter="wmic Path Win32_Battery Get DesignVoltage"
Substitute="DesignVoltage ":""
OutputType=ANSI
IfAboveValue=#minVoltage#
IfAboveAction=[!SetVariable ding 0]
IfBelowValue=#minVoltage#
IfBelowAction=[!SetVariable ding 1]


[measurePower]
Measure=Plugin
Plugin=PowerPlugin.dll
PowerState=ACLINE

[measureValue]
Measure=Calc
Formula=measureVoltage < #minVoltage# ? 1 : 0
DynamicVariables=1
You will need DynamicVariables=1 on [measureVoltage] as well.

http://docs.rainmeter.net/tips/dynamiccheatsheet