It is currently March 29th, 2024, 4:57 am

InputText SetVariable issue

Get help with creating, editing & fixing problems with skins
jove1661
Posts: 2
Joined: November 9th, 2018, 2:19 am

InputText SetVariable issue

Post by jove1661 »

I am having trouble with InputText and hope someone can help. It seems that it is either taking two inputs to set my variable or I am accessing the previous setting. I am not sure which and I have been staring at this for hours. Here is my code. Thanks.

Code: Select all

[Rainmeter]
Update=1000
AccurateText=1
Background=#@#Images/background_01.png
; #@# is equal to Rainmeter\Skins\portcheck\@Resources
BackgroundMode=3
BackgroundMargins=0,34,0,14
@includeStyleSheet=#@#StyleSheet.inc

[Metadata]
Name=
Author=
Information=
Version=
License=Creative Commons Attribution - Non - Commercial - Share Alike 3.0

[Variables]
myport=2510
porttype=1
porttext=TCP



[MeasureCheck]
DynamicVariables=1
Measure=Plugin
Plugin=RunCommand
Program= "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"
Parameter="C:\Powershell\PortCheck.ps1" #porttype# #myport#
State=Show
OutputType=ANSI

[MeterToggle]
DynamicVariables=1
Meter=String
FontSize=12
FontColor=170,170,170,255
SolidColor=47,47,47,255
Padding=5,6,5,4
AntiAlias=1
X=0
Y=5
W=35
H=20
Text=#porttext#
LeftMouseUpAction=[!UpdateMeasure MeasurePort]
UpdateDivider=-1

[MeterInputLabel]
Meter=String
X=50
Y=5
W=150
H=18
FontSize=12
FontColor=170,170,170,255
SolidColor=47,47,47,255
Padding=5,6,5,4
StringStyle=Italic
AntiAlias=1
Text=Port to check
LeftMouseUpAction=[!CommandMeasure MeasureInput "ExecuteBatch All"]


[MeasureInput]
Measure=Plugin
Plugin=InputText
X=50
Y=5
W=190
H=20
FontSize=12
FontColor=255,255,255,255
SolidColor=47,47,47,255
AntiAlias=1
FocusDismiss=1
DefaultValue="Port to Check"
Command1=[!SetVariable myport "$UserInput$"][!WriteKeyValue Variables myport [MeasureInput]] [!UpdateMeter *][!Redraw]
Command2=[!CommandMeasure MeasureCheck "Run"]



[MeasurePort]
Measure=Calc
Formula=#porttype#
IfCondition=([MeasurePort] = 1)
IfTrueAction=!execute [!SetVariable porttype 2][!SetVariable porttext "UDP"][!UpdateMeter MeterToggle]
IfFalseAction=!execute [!SetVariable porttype 1][!SetVariable porttext "TCP"][!UpdateMeter MeterToggle]
DynamicVariables=1
UpdateDivider=-1
Last edited by eclectic-tech on November 9th, 2018, 3:59 am, edited 2 times in total.
Reason: Removed 'Bold' style from Command1 in the code...
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5384
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: InputText SetVariable issue

Post by eclectic-tech »

We do not have your background image, stylesheet, or powershell script (PortCheck.ps1)... all that makes it difficult to fully test. :-(
I can tell you that your input measure is working, it writes the new port value to the [Variables] section. :welcome:
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: InputText SetVariable issue

Post by balala »

Beside what eclectic-tech wrote, I'd say that you should have to include the value which you want to set with the !WriteKeyValue bang into quotes (Command2 option of [MeasureInput] measure): [!WriteKeyValue Variables myport "[MeasureInput]"]. This could be needed especially if the value you'd like to set, contains spaces.
jove1661
Posts: 2
Joined: November 9th, 2018, 2:19 am

Re: InputText SetVariable issue

Post by jove1661 »

Thank you for both of your responses. I figured out the issue. I had to [!UpdateMeasure MeasureCheck] in order to replace the myport variable before issuing the CommandMeasure, otherwise it retains the old value.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5384
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: InputText SetVariable issue

Post by eclectic-tech »

jove1661 wrote: November 9th, 2018, 1:43 pm Thank you for both of your responses. I figured out the issue. I had to [!UpdateMeasure MeasureCheck] in order to replace the myport variable before issuing the CommandMeasure, otherwise it retains the old value.
Yes... If you set UpdateDivider=-1 on measures or meters, you must manually update them to see any change.
The alternative in small skins would be to let them update at the default skin rate; that is not going to dramatically increase the load. :confused:

Glad you found the issue! :thumbup: