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

FileChoose [Ver.1.2.0.1]

Share and get help with Plugins and Addons
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: FileChoose [Ver.1.2.0.1]

Post by balala »

rbriddickk84 wrote: July 25th, 2022, 6:44 pm

Code: Select all

[FileChoosePlugin]
Command1=[!SetVariable AppNew1 """$[Path]$"""]

[SaverMeasure]
[!WriteKeyValue Variables App1 #AppNew1# "Pref.inc"]
I can't entirely follow you, but from the beginning there are some thing you should take into account:
SilverAzide is perfectly right. Quotes are always needed in such cases. Even if there are cases when they can be omitted, this is not a good idea. It's much better users to get used to use them. I mean ALWAYS, even if they are not needed. I didn't understand what [SaverMeasure] is above and what and where do you want to include the posted !WriteKeyValue bang, however in any case quoting the #AppNew1# variable is practically required and additionally make sure you have a DynamicVariables=1 option added to the [SaverMeasure] measure. This is needed, because the !WriteKeyValue bang has to use the value of the #AppNew1# variable, which has been set previously with the Command1 option of the [FileChoosePlugin] measure (at least if I'm not mistaken).
If the above doesn't help, please pack for first the config you have and upload the package here, because the posted code is not enough.
User avatar
Yincognito
Rainmeter Sage
Posts: 7025
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: FileChoose [Ver.1.2.0.1]

Post by Yincognito »

rbriddickk84 wrote: July 25th, 2022, 6:44 pm Firstly thank you very much for your time and help! Partially it worked. it solved the first time, but after that first time something happened, i don't know what that made it work for one time.
But now it sometimes do nothing without any errors, sometimes it produces errors. I am completely lost. I woul just be fine with if the Plugin would be able to directly write into the Pref.inc file.

It occoured to me that maybe there is like a cache thing issue or something. :???:

Also i don't know how to do correct syntax if i would like to write key with variable, like:

Code: Select all

[FileChoosePlugin]
Command1=[!SetVariable AppNew1 """$[Path]$"""]

[SaverMeasure]
[!WriteKeyValue Variables App1 #AppNew1# "Pref.inc"]
As SilverAzide said, normally you'd want to use quotes for every of the last 2 or 3 parameters of !WriteKeyValue, i.e. [!WriteKeyValue SomeSection SomeKey "SomeValue" "SomeFile"]. However, without testing the code or the plugin, you should pay attention to the notes posted by the plugin developer (including the spoiler) - some things are formatted including quotes and square brackets, so better to log them first in order to know how to manipulate them further in your bangs. Obviously, if ANY of the names, values or whatever that you use contains or could potentially contain spaces, quotes around those are mandatory, one way or another. If they come from the plugin, nice, if they don't, you'd have to add them yourself.

That being said, to me the $Something$ syntax looks similar to the one used in the InputText plugin or for mouse variables, bar the occasional square brackets, so probably most ways of dealing with the latter would work with the former as well. By the way, if you still can't do what you want, maybe packing a simple and short (as in minimal reproducible example) version of what you're trying to do and post it here could help. If you don't already figure out what was the issue when simplifying your skin to post it here, that is... :D
User avatar
rbriddickk84
Rainmeter Sage
Posts: 276
Joined: February 17th, 2014, 12:39 pm
Location: Hungary

Re: FileChoose [Ver.1.2.0.1]

Post by rbriddickk84 »

I used to use quotes, but with time as i experimented and in many cases worked without them. So i guess i just forgot about which is vital to have and which not. :)
balala wrote: July 25th, 2022, 7:19 pm I didn't understand what [SaverMeasure] is above and what and where do you want to include the posted !WriteKeyValue bang, however in any case quoting the #AppNew1# variable is practically required and additionally make sure you have a DynamicVariables=1 option added to the [SaverMeasure] measure.
I did have DynamicVariables in the "SaverMeasure". I just wrote the "SaverMeasure" as an example here to indicate whic measure does what.

But i think i just link my skin package here for sure :)
Yincognito wrote: July 25th, 2022, 7:23 pm
As SilverAzide said, normally you'd want to use quotes for every of the last 2 or 3 parameters of !WriteKeyValue, i.e. [!WriteKeyValue SomeSection SomeKey "SomeValue" "SomeFile"]. However, without testing the code or the plugin, you should pay attention to the notes posted by the plugin developer (including the spoiler) - some things are formatted including quotes and square brackets, so better to log them first in order to know how to manipulate them further in your bangs. Obviously, if ANY of the names, values or whatever that you use contains or could potentially contain spaces, quotes around those are mandatory, one way or another. If they come from the plugin, nice, if they don't, you'd have to add them yourself.

That being said, to me the $Something$ syntax looks similar to the one used in the InputText plugin or for mouse variables, bar the occasional square brackets, so probably most ways of dealing with the latter would work with the former as well.
Yes, i tryed the quotes around everywhere i thought it might be vital now, but nothing changed sadly.
I included my skin package, i didn't included the other @Resources folder which is one lvl up from this skin.
I have the structure: Skins\Controllet22\AppLauncher\
In the Controllet22 folder i have many other skins.
Attachments
Controllet22 - AppLAuncher_1.08.rmskin
(370.13 KiB) Downloaded 82 times
User avatar
rbriddickk84
Rainmeter Sage
Posts: 276
Joined: February 17th, 2014, 12:39 pm
Location: Hungary

Re: FileChoose [Ver.1.2.0.1]

Post by rbriddickk84 »

Ps.: I gotta hit the hay since it's pretty later here. I'll check things tomorrow if anything new appears here, approx 10hrs from now. ;-)
User avatar
Yincognito
Rainmeter Sage
Posts: 7025
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: FileChoose [Ver.1.2.0.1]

Post by Yincognito »

rbriddickk84 wrote: July 25th, 2022, 8:17 pm Ps.: I gotta hit the hay since it's pretty later here. I'll check things tomorrow if anything new appears here, approx 10hrs from now. ;-)
Well, if you didn't yet go to sleep, here is one way of doing it - change your TextComparator1 and similar measures to something like:

Code: Select all

[TextComparator1]
Measure=String
String=#App1#
RegExpSubstitute=1
Substitute="(?:^\[|\]$)":""
IfMatch=empty
IfMatchAction=[!SetVariable AplicNew#Num# [#CURRENTSECTION#]]
IfNotMatchAction=[!SetVariable AplicNew#Num# [#CURRENTSECTION#]][!SetVariable NameNew#Num# #Pname1#][!SetVariable IcoNew#Num# #Picon1#][!SetVariable Num (#Num#+1)]#Ux#
;OnUpdateAction=[!Log "1"]
DynamicVariables=1
UpdateDivider=-1

The regex in the substitute will eliminate the square brackets, and the current section use when setting the variable will make sure the just modified measure value is set as the value of the "new" variables, instead of the unmodified #AppN# value. Feel free to adapt this or put it wherever you actually want, because there are a lot of more or less duplicate stuff in your skin, and I'm not gonna decipher which is which now, LOL.
The Pref.inc file after adding Rainmeter, showing that it worked:

Code: Select all

[Variables]
PrgPth1=C:\Program Files\Rainmeter\Rainmeter.exe
PrgPth2=empty
PrgPth3=empty
PrgPth4=empty
PrgPth5=empty
PrgPth6=empty
PrgPth7=empty
PrgPth8=empty
PrgPth9=empty

PrgNm1=Rainmeter
PrgNm2=none
PrgNm3=none
PrgNm4=none
PrgNm5=none
PrgNm6=none
PrgNm7=none
PrgNm8=none
PrgNm9=none

PrgIco1=C:\Users\MyUserNameHere\Documents\Rainmeter\Skins\AppLauncher\IconCache\Rainmeter_exe.png
PrgIco2=empty.png
PrgIco3=empty.png
PrgIco4=empty.png
PrgIco5=empty.png
PrgIco6=empty.png
PrgIco7=empty.png
PrgIco8=empty.png
PrgIco9=empty.png

Active=1
ContOpen=0

Font1=Andromeda
Font2=Earth 2073
Font3=Nasalization Rg
Font4=neo latina
Font5=White Rabbit

[Additionals]
WindowsWallpaperColor=9,33,46,255
; or #09212E
Obviously, make sure that when you load those values back after a refresh or whatever, you use the appropriate number of quotes to deal with spaces, i.e. [blah blah blah "#AplicNew1#"] and so on. I'm saying this because you claimed you added the required quotes, but your Sorter measure still uses the unquoted #AplicNew1# and such syntax! ;-)
Last edited by Yincognito on July 25th, 2022, 8:57 pm, edited 1 time in total.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: FileChoose [Ver.1.2.0.1]

Post by balala »

rbriddickk84 wrote: July 25th, 2022, 7:48 pm Yes, i tryed the quotes around everywhere i thought it might be vital now, but nothing changed sadly.
This definitely is a missing quotes problem, as previously said. And you don't have the quotes, at least not in the code of the posted package. The !SetVariable: Skin "Files\Rainmeter\Rainmeter.exe]" not found (AppLauncher\AutoL.ini) error message (which I got when wanted to add Rainmeter, just for a tryout) definitely indicates this. When you're using a path which contains space(s) and have no quotes, Rainmeter thinks the value which has to be set is starting from the beginning, until the first space. What is following the first space should represent the next parameter (in this case the file in which the value should be written). If you add the quotes, you tell Rainmeter that the value is what you have between the quotes. Issue avoided.
So recommend you to add quotes everywhere to the value which has to be set with bangs, to file paths, config names and so on. For instance the first !WriteKeyValue bang of the Command1 option of the [Sorter] InputText plugin measure should be: Command1=[!WriteKeyValue Variables PrgPth1 "#AplicNew1#" "Pref.inc"]. But you have to do this in every bang of your code.
Generally speaking it would be extremely important to get understanding why those quotes are needed. Using them every time it should have been used, forms a habit of using them, avoiding the possibility of forgetting them. This is the best practice, which always should be used by every user.
User avatar
Yincognito
Rainmeter Sage
Posts: 7025
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: FileChoose [Ver.1.2.0.1]

Post by Yincognito »

balala wrote: July 25th, 2022, 8:55 pm This definitely is a missing quotes problem, as previously said. And you don't have the quotes, at least not in the code of the posted package. The !SetVariable: Skin "Files\Rainmeter\Rainmeter.exe]" not found (AppLauncher\AutoL.ini) error message (which I got when wanted to add Rainmeter, just for a tryout) definitely indicates this.
You're absolutely right about the quotes and the fact that the code still doesn't use them where needed, but I believe the error you got is actually because of the square brackets and not necessarily because of the missing quotes. I'm saying this because after doing the above change, I don't get the error anymore. I know such errors are usually because of missing quotes, I'm just deducing that in this particular case, something else in the syntax (i.e. the brackets) could be the culprit. Feel free to disagree though, I'm not 100% sure of it anyway, I was just saying... :???:
User avatar
rbriddickk84
Rainmeter Sage
Posts: 276
Joined: February 17th, 2014, 12:39 pm
Location: Hungary

Re: FileChoose [Ver.1.2.0.1]

Post by rbriddickk84 »

Hi there friendly people! :)

Okay, well i tried many ways to avoid the issue, like:
(When i want to add Winamp for e.g.: C:\Program Files (x86)\Winamp\winamp.exe)

[!WriteKeyValue Variables "PrgPth1" "#AplicNew1#" "Pref.inc"] - Came with error: !WriteKeyValue: Illegal path:C:\Program

[!WriteKeyValue Variables PrgPth1 "#AplicNew1#" "Pref.inc"] - Came with error: !WriteKeyValue: Illegal path:C:\Program

[!WriteKeyValue Variables PrgPth1 #AplicNew1# "Pref.inc"] - Came with error: !WriteKeyValue: File not found: ...Skins\Controllet22\AppLauncher\Files

Yet with the RegExp method what Yincognito suggested worked at that point that it saves everything without an error.
Now i am at work, and on my laptop, so different gear. And strangely without quotes it still saves the path too, but it generates error message in log :???:
Yincognito wrote: July 25th, 2022, 8:41 pm Well, if you didn't yet go to sleep, here is one way of doing it - change your TextComparator1 and similar measures to something like:

The regex in the substitute will eliminate the square brackets, and the current section use when setting the variable will make sure the just modified measure value is set as the value of the "new" variables, instead of the unmodified #AppN# value. Feel free to adapt this or put it wherever you actually want, because there are a lot of more or less duplicate stuff in your skin, and I'm not gonna decipher which is which now, LOL.


Obviously, make sure that when you load those values back after a refresh or whatever, you use the appropriate number of quotes to deal with spaces, i.e. [blah blah blah "#AplicNew1#"] and so on. I'm saying this because you claimed you added the required quotes, but your Sorter measure still uses the unquoted #AplicNew1# and such syntax! ;-)
So then i tried this as well, it did the trick in some way. :) So i keep this in my pocket till i completely understand what causes the problem. :D

I was thinking if this acts differently here on my laptop, i try my first basic intention with the FileChoose plugin command iteself, like:

Code: Select all

Command1=[!WriteKeyValue Variables PrgPth1 """$[Path]$""" "Pref.inc"][!WriteKeyValue Variables  PrgNm1 "$Name$" "Pref.inc"][!WriteKeyValue Variables  PrgIco1 "$Icon$" "Pref.inc"][!Refresh]
Super weirdly it is working here without any issues. O.O
This was the ever first way i tried to make the plugin work at home, but it produced the error right away and didn't do today did. :confused:

I will bring home this file when i am done here, and trying on my pc. So weird. I don't understand really.
balala wrote: July 25th, 2022, 8:55 pm This definitely is a missing quotes problem, as previously said. And you don't have the quotes, at least not in the code of the posted package. The !SetVariable: Skin "Files\Rainmeter\Rainmeter.exe]" not found (AppLauncher\AutoL.ini) error message (which I got when wanted to add Rainmeter, just for a tryout) definitely indicates this. When you're using a path which contains space(s) and have no quotes, Rainmeter thinks the value which has to be set is starting from the beginning, until the first space. What is following the first space should represent the next parameter (in this case the file in which the value should be written). If you add the quotes, you tell Rainmeter that the value is what you have between the quotes. Issue avoided.
So recommend you to add quotes everywhere to the value which has to be set with bangs, to file paths, config names and so on. For instance the first !WriteKeyValue bang of the Command1 option of the [Sorter] InputText plugin measure should be: Command1=[!WriteKeyValue Variables PrgPth1 "#AplicNew1#" "Pref.inc"]. But you have to do this in every bang of your code.
Generally speaking it would be extremely important to get understanding why those quotes are needed. Using them every time it should have been used, forms a habit of using them, avoiding the possibility of forgetting them. This is the best practice, which always should be used by every user.
I will surely spread quotes where i just can in the feature :lol: :thumbup:

I will test this at home, but untill the i thank you guys very much for your great help and time!!!!
User avatar
Yincognito
Rainmeter Sage
Posts: 7025
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: FileChoose [Ver.1.2.0.1]

Post by Yincognito »

rbriddickk84 wrote: July 26th, 2022, 7:49 amSo then i tried this as well, it did the trick in some way. :) So i keep this in my pocket till i completely understand what causes the problem. :D
No problem, understanding is the most important thing, so that you can avoid these kind of situations in the future. ;-)
I'm sure you could do this by also cleaning up your code a bit, but since it was faster for me to do it like I did, that's what I presented. The choice is yours on how to fix it - personally I'm a fan of slower solutions that work forever instead of fast solutions that have to be reapplied in every place where you need them. A good baseline structure makes your code easier to develop later on.
User avatar
rbriddickk84
Rainmeter Sage
Posts: 276
Joined: February 17th, 2014, 12:39 pm
Location: Hungary

Re: FileChoose [Ver.1.2.0.1]

Post by rbriddickk84 »

Yincognito wrote: July 26th, 2022, 12:00 pm No problem, understanding is the most important thing, so that you can avoid these kind of situations in the future. ;-)
I'm sure you could do this by also cleaning up your code a bit, but since it was faster for me to do it like I did, that's what I presented. The choice is yours on how to fix it - personally I'm a fan of slower solutions that work forever instead of fast solutions that have to be reapplied in every place where you need them. A good baseline structure makes your code easier to develop later on.
Very true, a bit hard to accomplish that tho, when you are trying to learn programming on a side in C# and java. :lol:
8 years wasn't enough for me to sweep clean my coding habits :oops:
Post Reply