It is currently April 16th, 2024, 11:08 am

Click to copy text?

Get help with creating, editing & fixing problems with skins
User avatar
sl23
Posts: 1140
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Click to copy text?

Post by sl23 »

I was wondering if it were possible to click on a string meter in order to copy it's text to the clipboard? Then you can paste that into whatever app you need it in.
- MuLab -
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Click to copy text?

Post by jsmorley »

sl23 wrote: September 1st, 2021, 9:41 am I was wondering if it were possible to click on a string meter in order to copy it's text to the clipboard? Then you can paste that into whatever app you need it in.
Yes, but a String meter has no "value". You will need to copy the value from the same measure(s) that the String meter is bound to.

https://docs.rainmeter.net/manual/bangs/#SetClip

Code: Select all

[MeterString]
Meter=String
MeasureName=SomeMeasure
LeftMouseUpAction=[!SetClip "[SomeMeasure]"]
DynamicVariables=1
For instance, I have this in my Network skin:

Code: Select all

LeftMouseUpAction=[!SetClip "[MeasureAdapterDesc]#CRLF#WAN:	[MeasureIPWeb]#CRLF#LAN:		[MeasureIPLan]#CRLF#Router:	[MeasureRouter]"][Play "#@#Sounds\Copy.wav"]
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5391
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Click to copy text?

Post by eclectic-tech »

Use !SetClip and your [##CURRENTSECTION#] variable.

Code: Select all

[sAllText]
FontFace=Trebuchet MS
FontSize=9
FontColor=#Color1#
AntiAlias=1
Text=[##CURRENTSECTION#]
UpdateDivider=-1
X=15R
Y=3r
LeftMouseUpAction=[!SetClip "\x[##CURRENTSECTION#]"]
When you click the 'text', this will send your text (the partial code and description) to the clipboard, and prefix it with \x so the pasted item will contain a useable character reference. Of course the description would need to be removed.
Maybe you can find a better way to just get the character code in the clip.
User avatar
balala
Rainmeter Sage
Posts: 16141
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Click to copy text?

Post by balala »

eclectic-tech wrote: September 1st, 2021, 10:22 am Use !SetClip and your [##CURRENTSECTION#] variable.

Code: Select all

[sAllText]
FontFace=Trebuchet MS
FontSize=9
FontColor=#Color1#
AntiAlias=1
Text=[##CURRENTSECTION#]
UpdateDivider=-1
X=15R
Y=3r
LeftMouseUpAction=[!SetClip "\x[##CURRENTSECTION#]"]
My comment / question has nothing to do with the original request / question, however wondering what are you meaning by [##CURRENTSECTION#]? I saw this variable written this way a few times these days and to be honest can't realize what it is. Seems to be a nesting variable, but it's finally not. So, what is it?
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5391
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Click to copy text?

Post by eclectic-tech »

balala wrote: September 1st, 2021, 10:29 am My comment / question has nothing to do with the original request / question, however wondering what are you meaning by [##CURRENTSECTION#]? I saw this variable written this way a few times these days and to be honest can't realize what it is. Seems to be a nesting variable, but it's finally not. So, what is it?
I had the same thoughts...
sl23 is using the #CurrentSection# Name as part of another variable that uses nested syntax in MeterStyle definition.
So if the current section name is [Icon1], [##CURRENTSECTION#] resolves to nested variable syntax of [#Icon1] which is the variable he want to deal with in that section. This lets him use it in a meter style and work with multiple section names.
User avatar
sl23
Posts: 1140
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Click to copy text?

Post by sl23 »

Thank you for your help.
@ JSMorley: the skins have no meters so this won't work, but thank you for the tip, I'll try to keep that in mind :thumbup:

@ eclectic-tech: again you saved the day! :D I'll try this when I get home. Thanks :thumbup:

Oh and thanks for the description on the nested variable, I hadn't a clue what is was doing, I just tried different syntax and got lucky! :rolmfao:

Also, I will be using the icon variable to copy from so won't need to adjust anything. That way, it's ready to use in another skin.
Last edited by sl23 on September 1st, 2021, 12:13 pm, edited 2 times in total.
- MuLab -
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Click to copy text?

Post by jsmorley »

sl23 wrote: September 1st, 2021, 12:08 pm Thank you for your help.
@ JSMorley: the skins have no meters so this won't work, but thank you for the tip, I'll try to keep that in mind :thumbup:
It's not really about measures as such. It's just that you need to define whatever text you want in the !SetClip bang, and that can be literal text, any #Variables# that you want, and / or any [SectionVariables] that get values from measures. My only point was to be clear that Meters have no intrinsic "value" of their own.
User avatar
sl23
Posts: 1140
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Click to copy text?

Post by sl23 »

That's good to know. I realised meters don't have a value, hence my question :D

I didn't even know there was a !SetClip bang. I'm on my phone which can be hard for my eyes to see, so thought I'd pose the question :oops:

Thank you for the feedback. Very much appreciated.
- MuLab -
User avatar
balala
Rainmeter Sage
Posts: 16141
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Click to copy text?

Post by balala »

eclectic-tech wrote: September 1st, 2021, 11:06 am sl23 is using the #CurrentSection# Name as part of another variable that uses nested syntax in MeterStyle definition.
So if the current section name is [Icon1], [##CURRENTSECTION#] resolves to nested variable syntax of [#Icon1] which is the variable he want to deal with in that section. This lets him use it in a meter style and work with multiple section names.
Oh, yep, maybe it makes sense this way. Interesting idea...
User avatar
sl23
Posts: 1140
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Click to copy text?

Post by sl23 »

I tried the code supplied by eclectic-tech above, but when pasted, I just get a strange character instead of the actual text. Any idea on how to fix this?

According to the manual, this is a limited operation. Meaning you can't specify something like:
[!SetClip sAllIcons Text "[##CURRENTSECTION#]"]
Or whatever would be required to set text from the current meter.

Here's what I have in the Style section that activates the copy. I tried the !SetClip at the beginning and here, in the middle to see if the order mattered:

Code: Select all

[sAllIcons]
FontFace=Segoe Fluent Icons
FontSize=14
FontColor=#Color1#
AntiAlias=1
Text=[##CURRENTSECTION#]
LeftMouseUpAction=[!EnableMouseAction * "MouseOverAction|MouseLeaveAction"] [!SetClip "[##CURRENTSECTION#]"][!SetVariable Preview [##CURRENTSECTION#]] [!SetOptionGroup Preview FontColor "#Color1#"] [!UpdateMeterGroup Preview] [!SetOption #CURRENTSECTION# FontColor "#Color4#"] [!UpdateMeter #CURRENTSECTION#] [!Redraw] [!DisableMouseAction #CurrentSection# "MouseOverAction|MouseLeaveAction"]
UpdateDivider=-1
DynamicVariables=1
X=185
Y=5R
- MuLab -