It is currently April 19th, 2024, 8:04 pm

InputText Limitations Question

General topics related to Rainmeter.
finalfantasyaddict
Posts: 6
Joined: August 2nd, 2014, 11:04 am

InputText Limitations Question

Post by finalfantasyaddict »

I am trying to make a Meter which can be used to customise Variable values within an external skin.
There are a few questions I have with it though which I have a feeling can probably be fixed with Lua (which I know not alot of).
If there is a none Lua way of getting around it, it would be great.
Otherwise I am up for any way I can get a similar end result.
Or if none of it is possible I guess I will have to come up with a different way around it.

1. Is there a way to limit the amount of characters allowed in an InputText meter?

2. Is there a way to limit the use of certain characters / blank space?

3. If 2. is not possible is there a way to substitute a blank space with something else? (I have already tried [RegExpSubstitute=1 Substitute="A":"a","B":"b","C":"c"... without any success])

4. When using InputText I have noticed that when no value is entered and the data is !WriteKeyValue, the measure saves "". Is there a way to get around this (For example saving a previous value)?

5. On the same vein as 4., if one clicks on the InputText and then enters nothing (for example backspacing the DefaultValue value and then !WriteKeyValue that nothing value it updates as "" (as I am sure it should do with "" as it's value)

6. A possible workaround I though about was using IfConditions or equivalent when the next question hit (I couldn't find an answer in either the manual or the Forums), Can you use
!WriteKeyValue Commands with IfConditions? If so and I have somehow missed how this is possible please let me know. Even if it is complicated yet semi-possible through some long work-around it would be fine. If it isn't possible then again I would have to think of a different way of doing it. (I have ideas that might work but I wanted to check there wasn't an easier way of doing it first.



Apologies for the large amount of questions but this information did not seem so readily available and it seemed a waste to start different threads on a similar topic.



Some sample code of what I have been working with at the moment.

The config I have written so far (a shortened example is listed below) currently does the following...
- Displays a list of (drive) letters based of of existing Variable values.
- When a letter is clicked on and then a (drive) letter is written inside it (using InputText), the variable is set in memory (!SetVariable)
- This memory variable then updates and displays in place of the letter clicked on
- Upon finishing letter assigning, the confirm meter is pressed (somewhat like the Windows Settings "Apply" button)
- The Variable value is updated in both the initial config folder (for display the next time it is opened) and the in the config folder of the skin in which the value is concerned (obviously if this is not updated, there is no reason to have this particular skin)
- The config files are then refreshed (to initialise the writen value from before)

Code: Select all

[Variables]
fontcolor=255,0,0,255
fontsize=15

drive2=f

;-----

[MeasureDrive2]
Measure=Plugin
Plugin=InputText
DefaultValue="#drive2#"
Command1=[!SetVariable drive2 "$UserInput$"]
Command2=[!WriteKeyValue Variables drive2 "[MeasureDrive2]" "#SKINSPATH#\TestSkin\TestSections\TestResults.ini"]
Command3=[!WriteKeyValue Variables drive2 "[MeasureDrive2]"]
Command4=[!Refresh #CURRENTCONFIG#]

;-----

[MeterDrive2]
Meter=String
X=5
Y=10
FontSize=#fontsize#
FontColor=#fontcolor#
AntiAlias=1
Text="#drive2#"
LeftMouseUpAction=[!CommandMeasure "MeasureDrive2" "ExecuteBatch 1"]
DynamicVariables=1

[MeterConfirm]
Meter=String
X=5
Y=30
FontSize=#fontsize#
FontColor=#fontcolor#
AntiAlias=1
Text="Confirm"
LeftMouseUpAction=[!CommandMeasure "MeasureDrive2" "ExecuteBatch 2-4"]
DynamicVariables=1
User avatar
killall-q
Posts: 305
Joined: August 14th, 2009, 8:04 am

Re: InputText Limitations Question

Post by killall-q »

You can use $UserInput$ to set a variable or pass it to Lua.

Code: Select all

Command1=[!SetVariable Input """$UserInput$"""][!CommandMeasure MeasureScript Input() #CURRENTCONFIG#]

function Input()
   local input = SKIN:GetVariable('Input')
   if input ~= "" then
      ...
   end
end
"Magic quotes" (""") make it so inputting quotes won't break the skin.

Then you can use string.lower.

See this example notes skin for implementation demo.