It is currently April 19th, 2024, 4:05 am

[Solved] Transparency change on Middle Mouse Click

Get help with creating, editing & fixing problems with skins
admuralchik
Posts: 7
Joined: April 26th, 2022, 12:51 pm

[Solved] Transparency change on Middle Mouse Click

Post by admuralchik »

Hi, I was wondering if I can get some help on this forum. I wanted to modify a skin in Rainmeter, so when I click the middle mouse button it would set the transparency to 255 and when I click again, it would set it back to 1. I did the first part: the skin stays on the screen after I click the mouse wheel. I don't know what command should I use to set it back to 1 after I click it again.

Here is the code:

Code: Select all

[Rainmeter]
Update=#Rm.Update#
DynamicWindowSize=1
Rightmouseupaction=[!SkinCustomMenu]
ContextTitle=Config
ContextAction=[!ActivateConfig "Plainext\@Settings" "Info.ini"][!DeactivateConfig]
OnRefreshAction=[!Delay 1000][!CommandMeasure MeasureCPUName "Run"][!CommandMeasure MeasureGPUName "Run"][!CommandMeasure MeasureMotherboardname "Run"][!CommandMeasure CPUPhyC "Run"][!CommandMeasure CPUVirC "Run"]
LeftMouseUpAction=["taskmgr.exe"]
MiddleMouseDownAction=[!SetTransparency "255"] 
I've added only two last lines in there.
Last edited by admuralchik on April 26th, 2022, 11:47 pm, edited 1 time in total.
User avatar
CodeCode
Posts: 1365
Joined: September 7th, 2020, 2:24 pm
Location: QLD, Australia

Re: Transparency change on Middle Mouse Click

Post by CodeCode »

This is to control a skin that is an image of a 1920x1080 black.

Code: Select all

[Rainmeter]
Update=1000
Group=Light1

[Variables]
ImageNumber=0
;default setting:
Alpha=240

[MeterQuote]
Meter=Image
ImageName=Image.png
ImageAlpha=#Alpha#
X=1
Y=1
H=1079
W=1919
UpdateDivider=-1
MouseScrollUpAction=[!WriteKeyValue Variables "Alpha" "(Clamp((#Alpha#-15),1,255))"][!Refresh]
MouseScrollDownAction=[!WriteKeyValue Variables "Alpha" "(Clamp((#Alpha#+15),1,255))"][!Refresh]
AntiAlias=1
PreserveAspectRatio=1
DynamicVariables=1
It is independent from other skins but this code should help, I hope. 8-)

You can easily substitute an image of a different screen dimension and name it Image.png or whatever you like.
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
User avatar
CodeCode
Posts: 1365
Joined: September 7th, 2020, 2:24 pm
Location: QLD, Australia

Re: Transparency change on Middle Mouse Click

Post by CodeCode »

Sorry about updating the post as you look. :oops:
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
admuralchik
Posts: 7
Joined: April 26th, 2022, 12:51 pm

Re: Transparency change on Middle Mouse Click

Post by admuralchik »

CodeCode wrote: April 26th, 2022, 1:19 pm This is to control a skin that is an image of a 1920x1080 black.

Code: Select all

[Rainmeter]
Update=1000
Group=Light1

[Variables]
ImageNumber=0
;default setting:
Alpha=240

[MeterQuote]
Meter=Image
ImageName=Image.png
ImageAlpha=#Alpha#
X=1
Y=1
H=1079
W=1919
UpdateDivider=-1
MouseScrollUpAction=[!WriteKeyValue Variables "Alpha" "(Clamp((#Alpha#-15),1,255))"][!Refresh]
MouseScrollDownAction=[!WriteKeyValue Variables "Alpha" "(Clamp((#Alpha#+15),1,255))"][!Refresh]
AntiAlias=1
PreserveAspectRatio=1
DynamicVariables=1
It is independent from other skins but this code should help, I hope. 8-)

You can easily substitute an image of a different screen dimension and name it Image.png or whatever you like.
Ok, thank you for the suggested solution.

However, I don't think that's what I'm looking for. Firstly, I'm pretty sure that my skin is just a text, not an image (look at the picture attached). Secondly, I want to control transparency with a click, not scrolling up and down.
Screenshot 2022-04-26 164142.jpg
You do not have the required permissions to view the files attached to this post.
admuralchik
Posts: 7
Joined: April 26th, 2022, 12:51 pm

Re: Transparency change on Middle Mouse Click

Post by admuralchik »

Maybe the full code from the main.ini would be more useful...

Code: Select all

[Rainmeter]
Update=#Rm.Update#
DynamicWindowSize=1
Rightmouseupaction=[!SkinCustomMenu]
ContextTitle=Config
ContextAction=[!ActivateConfig "Plainext\@Settings" "Info.ini"][!DeactivateConfig]
OnRefreshAction=[!Delay 1000][!CommandMeasure MeasureCPUName "Run"][!CommandMeasure MeasureGPUName "Run"][!CommandMeasure MeasureMotherboardname "Run"][!CommandMeasure CPUPhyC "Run"][!CommandMeasure CPUVirC "Run"]
LeftMouseUpAction=["taskmgr.exe"]
MiddleMouseDownAction=[!SetTransparency "255"]

@includeCtx=#SKINSPATH##JaxCore\CoreShell\}{CtxItms.inc
[Variables]

@includeVars=#@#Vars.inc
Blacklist="_Total|Idle|dwm"

W=(500*#scale#)
Sec.Ctx.Left=1

@includeGS=#@#Includes\GlobalStyles.inc

@includeMAINM=@Measures\MAINM.inc


; = = = = = METERS = = = = =

@includePrefix=@#Prefix#\Prefix.inc

@includeName=@#Name#\Name.inc

@includeTime=@#Time#\Time.inc

[Dot1]
Meter=String
MeterStyle=Dots | FirstAlign:#Align#

@includeRAM=@#RAM#\RAM.inc

@includeCPU=@#CPU#\CPU.inc

@includeGPU=@#GPU#\GPU.inc

@includeDisk=@#Drives#\Drives.inc

@includeMisc=@#Misc#\Misc.inc

@includeStyle=@#CompactLook#\Overview.inc
User avatar
CodeCode
Posts: 1365
Joined: September 7th, 2020, 2:24 pm
Location: QLD, Australia

Re: Transparency change on Middle Mouse Click

Post by CodeCode »

Well the idea is to try and use a variable to manage the alpha value;

LeftMouseUpAction=[SetVariable Alpha "1"][!Update]
RightMouseUpAction=[SetVariable Alpha "255"][!Update]

EDIT = Took out the #s = not needed.
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
admuralchik
Posts: 7
Joined: April 26th, 2022, 12:51 pm

Re: Transparency change on Middle Mouse Click

Post by admuralchik »

CodeCode wrote: April 26th, 2022, 2:21 pm Well the idea is to try and use a variable to manage the alpha value;

LeftMouseUpAction=[SetVariable Alpha "1"][!Update]
RightMouseUpAction=[SetVariable Alpha "255"][!Update]

EDIT = Took out the #s = not needed.
Yeah, I've tried that with
LeftMouseUpAction=[!SetTransparency "1"]
MiddleMouseDownAction=[!SetTransparency "255"]

And it definitely works. I guess it will work with SetVariable Alpha the same way, the problem is that I don't want to use different buttons for that. I want this command to work with one MiddleMouseDownAction (or MiddleMouseUpAction)

Update: nope, it doensn't work with SetVariable Alpha for me
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Transparency change on Middle Mouse Click

Post by balala »

admuralchik wrote: April 26th, 2022, 1:45 pm Maybe the full code from the main.ini would be more useful...
No, actually the posted code is not the full code and is useless in our case, because it has a lot of @Include options, which are linked to a lot of unknown files. But it's not even needed...
admuralchik wrote: April 26th, 2022, 1:09 pm I wanted to modify a skin in Rainmeter, so when I click the middle mouse button it would set the transparency to 255 and when I click again, it would set it back to 1. I did the first part: the skin stays on the screen after I click the mouse wheel. I don't know what command should I use to set it back to 1 after I click it again.
Here is a solution, which I hope does what you want. Same way as in the posted codes, this uses a variable called Alpha, which sets the transparency of the skin, but there is a trick. The value of this variable varies between 0 (when the transparency is 1, so practically the skin is not visible) and 1 (when the skin is opaque). So for first add this variable to the [Variables] section:

Code: Select all

[Variables]
...
Alpha=1
Note that the skin starts with a transparency according to the set value of this variable. If you set it to 1 (as above), the skin is visible when is loaded / refreshed. With Alpha=0, the skin is not visible, being almost transparent.
Now add the following measure to your code:

Code: Select all

[MeasureTransparency]
Measure=Calc
Formula=#Alpha#
OnChangeAction=[!SetTransparency "(1+254*#Alpha#)"]
DynamicVariables=1
And finally use the following MiddleMouseDownAction (or usually even better MiddleMouseUpAction) in the [Rainmeter] section of your skin: MiddleMouseDownAction=[!SetVariable Alpha "(1-[#Alpha])"][!UpdateMeasure "MeasureTransparency"]. As you can see here when you middle click the skin, the value of the Alpha variable is switched between 0 and 1, which changes the value of the [MeasureTransparency] measure. The OnChangeAction option of this measure sets the transparency of the skin accordingly.
Does this what you want?
admuralchik
Posts: 7
Joined: April 26th, 2022, 12:51 pm

Re: Transparency change on Middle Mouse Click

Post by admuralchik »

balala wrote: April 26th, 2022, 4:13 pm Here is a solution, which I hope does what you want. Same way as in the posted codes, this uses a variable called Alpha, which sets the transparency of the skin, but there is a trick. The value of this variable varies between 0 (when the transparency is 1, so practically the skin is not visible) and 1 (when the skin is opaque). So for first add this variable to the [Variables] section:

Code: Select all

[Variables]
...
Alpha=1
Note that the skin starts with a transparency according to the set value of this variable. If you set it to 1 (as above), the skin is visible when is loaded / refreshed. With Alpha=0, the skin is not visible, being almost transparent.
Now add the following measure to your code:

Code: Select all

[MeasureTransparency]
Measure=Calc
Formula=#Alpha#
OnChangeAction=[!SetTransparency "(1+254*#Alpha#)"]
DynamicVariables=1
And finally use the following MiddleMouseDownAction (or usually even better MiddleMouseUpAction) in the [Rainmeter] section of your skin: MiddleMouseDownAction=[!SetVariable Alpha "(1-[#Alpha])"][!UpdateMeasure "MeasureTransparency"]. As you can see here when you middle click the skin, the value of the Alpha variable is switched between 0 and 1, which changes the value of the [MeasureTransparency] measure. The OnChangeAction option of this measure sets the transparency of the skin accordingly.
Does this what you want?
You are a saint man. It works perfectly, thank you!
admuralchik
Posts: 7
Joined: April 26th, 2022, 12:51 pm

Re: Transparency change on Middle Mouse Click

Post by admuralchik »

I think my brain would spill out of my head if I tried to do this by myself