It is currently April 5th, 2020, 3:44 am

Working with InputText

Our most popular Tips and Tricks from the Rainmeter Team and others
User avatar
pul53dr1v3r
Posts: 336
Joined: July 30th, 2014, 10:30 am

Re: Working with InputText

Post by pul53dr1v3r »

eclectic-tech wrote:
December 5th, 2019, 1:29 am
Hi ET.
Your solution works with the forbidden language tags but unfortunately not with the others. :confused:
Try to enter another language tag, pt-PT, es-ES...
jsmorley wrote:
December 5th, 2019, 1:22 am


I don't follow that a bit.
just enter a language tag, for example en-US in the InputBox and the "picture" will explain you a thousand words.
You can use ET's code.
User avatar
jsmorley
Developer
Posts: 20440
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Working with InputText

Post by jsmorley »

The issue is with:

IfNotMatchAction=["#MyVar#"]

If the string value of MyVar is "en-US" then that is executed as a run command in Windows. In Windows, if you execute en-US at a command prompt, you get that language folder opened in Explorer. I wasn't aware of that, but nothing in Windows really surprises me anymore.

Not sure what you can do about that, since you are just executing whatever the user types in. That could be anything, including cmd commands that could have very unfortunate results. I don't really understand why you would have a Rainmeter skin that attempts to be a command line replacement. I just don't agree with using Rainmeter this way.

But, to each his own...
User avatar
pul53dr1v3r
Posts: 336
Joined: July 30th, 2014, 10:30 am

Re: Working with InputText

Post by pul53dr1v3r »

jsmorley wrote:
December 5th, 2019, 7:00 pm
The issue is with:

IfNotMatchAction=["#MyVar#"]

If the string value of MyVar is "en-US" then that is executed as a run command in Windows. In Windows, if you execute en-US at a command prompt, you get that language folder opened in Explorer. I wasn't aware of that, but nothing in Windows really surprises me anymore.

Not sure what you can do about that, since you are just executing whatever the user types in. That could be anything, including cmd commands that could have very unfortunate results. I don't really understand why you would have a Rainmeter skin that attempts to be a command line replacement. I just don't agree with using Rainmeter this way.

But, to each his own...
no Morley, i don't want it at all. I want to enter any language tag without opening the folders. ET's solution solves it if a tag is forbidden in the code. i'd also like to get rid of it if a tag isn't forbidden. So, i DON'T WANT cmd to be executed.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 3861
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Working with InputText

Post by eclectic-tech »

@ jsmorley Yes, I was also surprised that that input opened the associated language folder... Windows can be too smart for it's own good. :D
Pul53dr1v3r wrote:
December 5th, 2019, 7:11 pm
no Morley, i don't want it at all. I want to enter any language tag without opening the folders. ET's solution solves it if a tag is forbidden in the code. i'd also like to get rid of it if a tag isn't forbidden. So, i DON'T WANT cmd to be executed.
Looking at your code, I don't understand why you want to execute the $UserInput$ anyway; normally the result is set as a variable value or written for use later after a refresh.

To eliminate the folder opening just remove the execution command from
IfNotMatchAction=["#MyVar#"][Bang][Bang]
becomes
IfNotMatchAction=[Bang][Bang]
User avatar
pul53dr1v3r
Posts: 336
Joined: July 30th, 2014, 10:30 am

Re: Working with InputText

Post by pul53dr1v3r »

eclectic-tech wrote:
December 5th, 2019, 7:28 pm
To eliminate the folder opening just remove the execution command from
IfNotMatchAction=["#MyVar#"][Bang][Bang]
Oh no...
ET,
haven't you added this problematic command along with [MeasureInputAction] measure?
https://forum.rainmeter.net/viewtopic.php?f=118&t=18060&start=60#p168784

Do you see it in any previous post about this issue? i don't. i also didn't know what's the use of it, to be honest because i didn't add it.

So, who muddied the waters? ;-)
User avatar
jsmorley
Developer
Posts: 20440
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Working with InputText

Post by jsmorley »

Pul53dr1v3r wrote:
December 5th, 2019, 7:58 pm
Oh no...
ET,
haven't you added this problematic command along with [MeasureInputAction] measure?
https://forum.rainmeter.net/viewtopic.php?f=118&t=18060&start=60#p168784

Do you see it in any previous post about this issue? i don't. i also didn't know what's the use of it, to be honest because i didn't add it.

So, who muddied the waters? ;-)
I guess I did, in my original suggested code. Let me chew on how to avoid having what is typed in "executed".

Edit: I guess you never want to just use [$UserInput$] in a Command[n] option in InputText, as that will do two unavoidable things. First, set the value of the InputText measure to whatever is typed in, and second, attempt to execute whatever is typed in. I think you always want to use $UserInput$ in the context of some bang, !SetOption, !SetVariable, !WriteKeyValue, whatever.
User avatar
jsmorley
Developer
Posts: 20440
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Working with InputText

Post by jsmorley »

I'm not sure this is the most efficient way to do this, but at first blush I think:

Code: Select all

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

[Variables]
MyVar=Starting Value

[MeasureString]
Measure=String
Disabled=1
UpdateDivider=-1
DynamicVariables=1
IfMatchMode=1
IfMatch=(?i)^jsmorley$|^pul53dr1v3r$
IfMatchAction=[Play error]
IfNotMatchAction=[!SetVariable MyVar "[MeasureString]"]

[MeterSearchBox]
Meter=Shape
Shape=Rectangle 1,1,202,25 | Fill Color 215,215,215,255 | Stroke Color 130,130,130,255
W=202
H=25

[MeterSearchLabel]
Meter=String
X=5
Y=4
W=200
H=23
SolidColor=0,0,0,1
FontColor=47,47,47,255
FontFace=Fira Sans
FontSize=12
AntiAlias=1
Text=Enter here
LeftMouseUpAction=[!CommandMeasure "MeasureInput" "ExecuteBatch 1"]

[MeasureInput]
Measure=Plugin
Plugin=InputText
X=1
Y=2
W=200
H=22
SolidColor=200,200,200,255
FontColor=47,47,47,255
FontFace=Fira Sans
FontSize=11
AntiAlias=1
FocusDismiss=1
Command1=[!EnableMeasure MeasureString][!SetOption MeasureString String "$UserInput$"][!UpdateMeasure MeasureString]
So you use !SetOption to pass the value captured in $UserInput$ to a String measure, then do the IfMatch evaluation there and take whatever actions you want.
User avatar
Yamajac
Posts: 134
Joined: June 30th, 2014, 8:44 am

Re: Working with InputText

Post by Yamajac »

jsmorley wrote:
December 5th, 2019, 9:32 pm

Note that I have to hammer the String measure with !DisableMeasure and !EnableMeasure to force the IfMatch to be evaluated each time, even if the result doesn't change from "true" to "false".
Just use IfMatchMode = 1.

I haven't looked into it but doesn't the inputtext plugin store the last value it had, so you'd be able to do IfMatch just right on the input textplugin instead?
User avatar
jsmorley
Developer
Posts: 20440
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Working with InputText

Post by jsmorley »

Yamajac wrote:
December 5th, 2019, 9:38 pm
Just use IfMatchMode = 1.

I haven't looked into it but doesn't the inputtext plugin store the last value it had, so you'd be able to do IfMatch just right on the input textplugin instead?
Yeah, I edited my post just before you posted... I was afraid it might run-away with beeps, but the UpdateDivider=-1 takes care of that.
User avatar
Yamajac
Posts: 134
Joined: June 30th, 2014, 8:44 am

Re: Working with InputText

Post by Yamajac »

jsmorley wrote:
December 5th, 2019, 9:40 pm
Yeah, I edited my post just before you posted... I was afraid it might run-away with beeps, but the UpdateDivider=-1 takes care of that.
Oh lol, my bad. :D