It is currently March 29th, 2024, 12:25 pm

[SOLVED] How to get local image link from txt.file

Get help with creating, editing & fixing problems with skins
Nachtschade
Posts: 24
Joined: August 1st, 2017, 10:02 pm

[SOLVED] How to get local image link from txt.file

Post by Nachtschade »

Hello,

I'm building a very simple skin that needs to display a single image on my desktop. However the image to be displayed changes. The path to the image that should be displayed at a specific time is automatically updated into a .txt file by another program. The .txt file only has a single line with the path, no other content.

What do I need to do to make this dynamic?

Currently the skin config simply reads:

ImageName=C:\image.ico

And it needs to refer to C:\.txt file that contains the path to the actual image.

Hope I explained that well enough. Thanks for reading. :)
Last edited by Nachtschade on May 3rd, 2018, 11:40 am, edited 1 time in total.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: How to get local image link from txt.file

Post by balala »

Nachtschade wrote:Hope I explained that well enough.
Yep, you probably did.
Here is a short code:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1

[Variables]

[MeasurePath]
Measure=WebParser
UpdateRate=900
Url=file://PATH-TO-THE-.txt-FILE
RegExp=(?siU)^(.*)$
StringIndex=1
FinishAction=[!ShowMeter "MeterImage"]

[MeterImage]
Meter=Image
MeasureName=MeasurePath
X=0
Y=0
W=120
H=90
PreserveAspectRatio=1
Hidden=1

[MeterPath]
MeasureName=MeasurePath
Meter=STRING
X=0
Y=0
Padding=15,5,15,5
FontColor=220,220,220
SolidColor=0,0,0,150
FontSize=8
FontFace=Segoe UI
StringStyle=BOLD
StringAlign=Left
AntiAlias=1
Text=Path: %1
The above code works if you add the path of the .txt file to the Url option of the [MeasurePath] AND in this file just the appropriate path is stored (according to the RegExp option, the complete content of the file is read, from its start, to the end). When the [MeasurePath] measure succeeded to read the path from the file, the [MeterImage] shows up the image. Initially this meter is hidden (due to its Hidden=1 option), but when the WebParser measure read the path, its FinishAction shows up the [MeterImage] image meter.
I added the [MeterPath] meter to have something on the skin, just in case if something is going wrong and the image doesn't appear. If everything is ok, you can remove this meter.
Please let me know if this code works as you intended.
Nachtschade
Posts: 24
Joined: August 1st, 2017, 10:02 pm

Re: How to get local image link from txt.file

Post by Nachtschade »

Thank you.

It's not working yet though.

I get this as a result:

Image

Which is the correct path to the image that is in the text file that the skin must read. The actual image however doesn't show up.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: How to get local image link from txt.file

Post by balala »

Nachtschade wrote:The actual image however doesn't show up.
For me it is. Please post the Croatia.ico file, to can check.
Nachtschade
Posts: 24
Joined: August 1st, 2017, 10:02 pm

Re: How to get local image link from txt.file

Post by Nachtschade »

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

Re: How to get local image link from txt.file

Post by balala »

Nachtschade wrote:This is the file: https://www107.zippyshare.com/v/HSfrjLyq/file.html
It does work for me. Perfectly. The image is shown up.
Please pack the whole config and upload it.
Nachtschade
Posts: 24
Joined: August 1st, 2017, 10:02 pm

Re: How to get local image link from txt.file

Post by Nachtschade »

The .ini, Basically a full copy of your code, with the link to the .txt file added.

https://www6.zippyshare.com/v/lODBD0ld/file.html

Also the .txt file itself:

https://www6.zippyshare.com/v/eL2Ld8Y9/file.html

I'm sure it must be something obvious that I'm doing wrong because I fail at being smart.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: How to get local image link from txt.file

Post by balala »

Nachtschade wrote:The .ini, Basically a full copy of your code, with the link to the .txt file added.

https://www6.zippyshare.com/v/lODBD0ld/file.html

Also the .txt file itself:

https://www6.zippyshare.com/v/eL2Ld8Y9/file.html

I'm sure it must be something obvious that I'm doing wrong because I fail at being smart.
Are you sure about the paths of the Croatia.ico and npcountryflag.txt files? A: and B: today are very weird places for those files (however if the appropriate file path is shown up by the String meter, I think they are ok).
But I asked for the whole config packed, not just two files. Sometimes it is much better. Please pack the Config (the folder in the Skins folder, which contains the FlagVies.ini file) and upload that one.
Nachtschade
Posts: 24
Joined: August 1st, 2017, 10:02 pm

Re: How to get local image link from txt.file

Post by Nachtschade »

Yeah, the paths are most certainly okay, including the driveletters.

I'm not sure I understand about the 'package'? In the skins folder there is a folder called 'flagview' which contains one file called 'flagview.ini'. I send you the file. I could of course use winzip to 'package' the folder with the one file and send that but is that really what you mean?
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: How to get local image link from txt.file

Post by balala »

Nachtschade wrote:I'm not sure I understand about the 'package'? In the skins folder there is a folder called 'flagview' which contains one file called 'flagview.ini'. I send you the file. I could of course use winzip to 'package' the folder with the one file and send that but is that really what you mean?
No, if there is just one single file (FlagView.ini) no need to pack the config. I thought maybe there are more.
But if the image isn't shown up, I don't know what to say. Open the log and refresh the skin. Does any message appears?