It is currently March 28th, 2024, 11:31 pm

running a program to update an MeterImage

Get help with creating, editing & fixing problems with skins
medvejonok
Posts: 8
Joined: December 4th, 2017, 5:37 pm

Re: running a program to update an MeterImage

Post by medvejonok »

Hi all,

I've tried balala and jsmorley's codes,

had a bit of trouble making the things work, was banging my head on the wall not seeing whether Powershell was actually executing or not.

In the end I've managed to make the image download work on jsmorley base,
using the opensource software curl to download the image, rather than powershell. (https://curl.haxx.se)

I am not sure yet whether the regular refresh of the image will occur, still need to check that.

The code looks like this:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
OnRefreshAction=[!CommandMeasure MeasureGetImage "Run"]

[Variables]
InImage=https://storage.googleapis.com/trdemo/testimage.png
OutImage=#@#test.png

[MeasureGetImage]
Measure=Plugin
Plugin=RunCommand
Program=""C:\path-to\curl.exe""
Parameter="-k --output "#OutImage#" #InImage#"
State=Show 
FinishAction=[!SetOption MeterImage ImageName "#OutImage#"][!UpdateMeter MeterImage]

[MeterImage]
Meter=Image
W=400
PreserveAspectRatio=1


I am not sure whether curl is indispensable and if powershell would actually work, but curl can be used in a portable form and I have spent a lot of time trying to get Powershell to work and not succeeded! It may be my company IT security settings. Curl seems to be OK with them.

presumably the Update=1000 setting would mean it would download every second? I am not seeing this for the moment, will try changing the settings to use an UpdateDivider setting to space out the downloads.

Thanks !

:thumbup:
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: running a program to update an MeterImage

Post by balala »

Two problems with the code you've posted:
  • In the Parameter option of the [MeasureGetImage] measure a quotation mark is missing: Parameter="-k --output "#OutImage#" [color=#FF0000]"[/color]#InImage#".
  • Don't use double quotation marks around the value of the Program option, in the [MeasureGetImage] measure. In fact nor even simple quotation marks aren't needed, the simple Program=C:\path-to\curl.exe form will work well: https://forum.rainmeter.net/viewtopic.php?p=137628#p137628
Beside these, although this can't make the code to not work, I'd replace the State=Show option of the same [MeasureGetImage] measure, with State=Hide. With the State=Show option, usually when the appropriate program is ran, a window opens, then closes. State=Hide avoids this.
I didn't try the curl.exe app and I won't even either, but I can say it works very well with PowerShell, unless those IT security settings don't permit the needed action. Here is another small code, using the PowerShell app:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
OnRefreshAction=[!CommandMeasure MeasureGetImage "Run"]

[Variables]
InImage=https://storage.googleapis.com/trdemo/testimage.png
OutImage=#@#test.png

[MeasureGetImage]
Measure=Plugin
Plugin=RunCommand
Program=powershell.exe
Parameter=iwr -outf #OutImage# #InImage#
State=Hide
FinishAction=[!SetOption MeterImage ImageName "#OutImage#"][!UpdateMeter MeterImage][!Redraw]

[MeterImage]
Meter=Image
W=400
PreserveAspectRatio=1
This code definitely works for me. If it doesn't for you, probably the security settings are guilty, indeed. In this case use jsmorley's solution.
medvejonok
Posts: 8
Joined: December 4th, 2017, 5:37 pm

Re: running a program to update an MeterImage

Post by medvejonok »

Thanks balala!

I have found why the image was not downloading regularly, I needed to add this to the [Rainmeter] section:

OnUpdateAction=[!CommandMeasure MeasureGetImage "Run"]

so that the meter keeps on updating, not just when it is first loaded


Thanks everyone, this is working for me with curl , Powershell outputs an error message that seems to be related to security settings. curl is very good in standalone so this is a solution.

So --- problem of authenticated proxy + Rainmeter solved!

Thank you!
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: running a program to update an MeterImage

Post by jsmorley »

medvejonok wrote:Thanks balala!

I have found why the image was not downloading regularly, I needed to add this to the [Rainmeter] section:

OnUpdateAction=[!CommandMeasure MeasureGetImage "Run"]

so that the meter keeps on updating, not just when it is first loaded


Thanks everyone, this is working for me with curl , Powershell outputs an error message that seems to be related to security settings. curl is very good in standalone so this is a solution.

So --- problem of authenticated proxy + Rainmeter solved!

Thank you!
Using OnUpdateAction in the [Rainemter] section is ok if your intent is to have the action take place once a second. I STRONGLY recommend that you not try to download that image once a second. That is just going to use insane amounts of bandwidith and other resources for no good reason.

Set up a measure like this:

Code: Select all

[MeasureUpdateImage]
Measure=Calc
UpdateDivider=300
OnUpdateAction=[!CommandMeasure MeasureGetImage "Run"]
That will update the image once every 5 minutes.
medvejonok
Posts: 8
Joined: December 4th, 2017, 5:37 pm

Re: running a program to update an MeterImage

Post by medvejonok »

Thanks jsmorley, this is much better and the images appear straight away.

To help anyone coming across this, the final code for me now is:

Code: Select all


[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
OnRefreshAction=[!CommandMeasure MeasureGetImage "Run"]

[Variables]
InImage= URL to the image to download
OutImage=#@#target_image_name.png

[MeasureUpdateImage]
Measure=Calc
UpdateDivider=300
OnUpdateAction=[!CommandMeasure MeasureGetImage "Run"]

[MeasureGetImage]
Measure=Plugin
Plugin=RunCommand
Program=path to curl.exe  (or powershell if this works for you, see posts above on irw syntax)
Parameter="-k --output "#OutImage#" #InImage#"
State=Hide
FinishAction=[!SetOption MeterImage ImageName "#OutImage#"][!UpdateMeter MeterImage]

[MeterImage]
Meter=Image
W=350
PreserveAspectRatio=1