It is currently April 19th, 2024, 8:11 am

How to copy user input text to clipboard?

Get help with creating, editing & fixing problems with skins
User avatar
PacBreezy
Posts: 2
Joined: May 19th, 2021, 6:55 am
Location: Tijuana, Mexico

How to copy user input text to clipboard?

Post by PacBreezy »

Hi all,

Can someone please help me copy the user entered text to clipboard? Here's my code:

Code: Select all

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

[Variables]
Var1=Input1
Var2=Input2

[MeterBackground]
Meter=Image
SolidColor=0,0,0,255 
W=250
H=65

[MeterOne]
Meter=String
X=5
Y=5
FontSize=16
FontColor=255,255,255,255
AntiAlias=1
DynamicVariables=1
Text=#Var1#
LeftMouseUpAction=!CommandMeasure "TextInput" "ExecuteBatch 1"

[MeterTwo]
Meter=String
X=0r
Y=5R
FontSize=16
FontColor=255,255,255,255
AntiAlias=1
DynamicVariables=1
Text=#Var2#
LeftMouseUpAction=!CommandMeasure "TextInput" "ExecuteBatch 2"

[TextInput]
Measure=Plugin
Plugin=InputText
SolidColor=255,255,255
FontColor=0,0,0,255
FontFace=Verdana
FontSize=14
AntiAlias=1
FocusDismiss=1
DefaultValue=""
X=5
Y=0
H=25
W=240
Command1=[!SetVariable Var1 "$UserInput$"] DefaultValue="#Var1#" Y=5
Command2=[!SetVariable Var2 "$UserInput$"] DefaultValue="#Var2#" Y=35

[CopyButton]
Meter=Button
ButtonImage=#@#Copy_Button.png
X=0
Y=10R
ButtonCommand=[!SetClip "#Var1#[\x0D]#Var2#"]
My problem is that the ButtonCommand=[!SetClip "#Var1#[\x0D]#Var2#"] copies the predefined value and not the changed value of Var1 & Var2. Please be noob friendly with me :)

Big thanks in advanced!
User avatar
death.crafter
Rainmeter Sage
Posts: 1399
Joined: April 24th, 2021, 8:13 pm

Re: How to copy user input text to clipboard?

Post by death.crafter »

PacBreezy wrote: May 19th, 2021, 7:38 am Hi all,

Can someone please help me copy the user entered text to clipboard? Here's my code:

Code: Select all

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

[Variables]
Var1=5
Var2=35

[MeterBackground]
Meter=Image
SolidColor=0,0,0,255 
W=250
H=65

[MeterOne]
Meter=String
X=5
Y=5
FontSize=16
FontColor=255,255,255,255
AntiAlias=1
DynamicVariables=1
Text=#Var1#
LeftMouseUpAction=!CommandMeasure "TextInput" "ExecuteBatch 1"

[MeterTwo]
Meter=String
X=0r
Y=5R
FontSize=16
FontColor=255,255,255,255
AntiAlias=1
DynamicVariables=1
Text=#Var2#
LeftMouseUpAction=!CommandMeasure "TextInput" "ExecuteBatch 2"

[TextInput]
Measure=Plugin
Plugin=InputText
SolidColor=255,255,255
FontColor=0,0,0,255
FontFace=Verdana
FontSize=14
AntiAlias=1
FocusDismiss=1
DefaultValue=""
X=5
Y=0
H=25
W=240
Command1=[!WriteKeyValue Variables Var1 "$UserInput$"][!Refresh]
Command2=[!WriteKeyValue Variables Var2 "$UserInput$"][!Refresh]

[CopyButton]
Meter=Button
ButtonImage=#@#Copy_Button.png
X=0
Y=10R
ButtonCommand=[!SetClip "#Var1#[\x0D]#Var2#"]
from the Realm of Death
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: How to copy user input text to clipboard?

Post by balala »

PacBreezy wrote: May 19th, 2021, 7:38 am Can someone please help me copy the user entered text to clipboard?
Add a DynamicVariables=1 option to the [CopyButton] meter.
User avatar
PacBreezy
Posts: 2
Joined: May 19th, 2021, 6:55 am
Location: Tijuana, Mexico

Re: How to copy user input text to clipboard?

Post by PacBreezy »

death.crafter wrote: May 19th, 2021, 9:12 am

Code: Select all

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

[Variables]
Var1=5
Var2=35

[MeterBackground]
Meter=Image
SolidColor=0,0,0,255 
W=250
H=65

[MeterOne]
Meter=String
X=5
Y=5
FontSize=16
FontColor=255,255,255,255
AntiAlias=1
DynamicVariables=1
Text=#Var1#
LeftMouseUpAction=!CommandMeasure "TextInput" "ExecuteBatch 1"

[MeterTwo]
Meter=String
X=0r
Y=5R
FontSize=16
FontColor=255,255,255,255
AntiAlias=1
DynamicVariables=1
Text=#Var2#
LeftMouseUpAction=!CommandMeasure "TextInput" "ExecuteBatch 2"

[TextInput]
Measure=Plugin
Plugin=InputText
SolidColor=255,255,255
FontColor=0,0,0,255
FontFace=Verdana
FontSize=14
AntiAlias=1
FocusDismiss=1
DefaultValue=""
X=5
Y=0
H=25
W=240
Command1=[!WriteKeyValue Variables Var1 "$UserInput$"][!Refresh]
Command2=[!WriteKeyValue Variables Var2 "$UserInput$"][!Refresh]

[CopyButton]
Meter=Button
ButtonImage=#@#Copy_Button.png
X=0
Y=10R
ButtonCommand=[!SetClip "#Var1#[\x0D]#Var2#"]
Ok, so in the Command line change !SetVariable to !WriteKeyValue? That did copied the user entered text to the clipboard but it also changed the predefined variable which doesn't help in my situation. Thanks tho!
balala wrote: May 19th, 2021, 9:52 am Add a DynamicVariables=1 option to the [CopyButton] meter.
Bro, no lie, I did as you suggested in this thread but it was confusing to me. I can't believe all I needed was DynamicVariables=1 to the button meter. I feel dumb. Anyways, thank you good sir! :bow:

Also, I want to thank you for this
balala wrote: May 22nd, 2020, 8:09 am Something like this: [!SetClip "#Mystring#[\x09]#Mystring#"]. Note the [\x09] character variable between the two #MyString# variables, which is the character for TAB.
I googled [\x09] and found out it was hex for tab. So I looked up hex for the new line, or enter, or return or whatever you call it, and applied to my case scenario
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: How to copy user input text to clipboard?

Post by balala »

PacBreezy wrote: May 19th, 2021, 3:24 pm Ok, so in the Command line change !SetVariable to !WriteKeyValue? That did copied the user entered text to the clipboard but it also changed the predefined variable which doesn't help in my situation. Thanks tho!
Yes, because death.crafter replaced your !SetVariable bangs with !WriteKeyValue, which permanently and phisically rewrites the variables.
PacBreezy wrote: May 19th, 2021, 3:24 pm Bro, no lie, I did as you suggested in this thread but it was confusing to me. I can't believe all I needed was DynamicVariables=1 to the button meter. I feel dumb. Anyways, thank you good sir! :bow:
No, no, don't feel dumb at all. The !SetVariable bang sets the variable, but the DynamicVariables=1 option is needed in the measure or meter where you want to use the variable. without it the measure or meter uses the original, phisically set value. This has happend in your case and this is why you can't use a variable set with !SetVariable in, for instance, the [Rainmeter] section, this section not accepting the dynamic variables.
PacBreezy wrote: May 19th, 2021, 3:24 pm Also, I want to thank you for this


I googled [\x09] and found out it was hex for tab. So I looked up hex for the new line, or enter, or return or whatever you call it, and applied to my case scenario
You're welcome. I'm glad if you found an answer.