I have an icon (image) that opens AIDA64 sensor panel via using a nircmd sendkeypress and it works perfectly. This is the code I have.
[App7]
Meter=Image
ImageName=Temp.png
w=18
h=18
X=1340
Y=3
HideOnMouseOver=0
FadeDuration=0
AlphaValue=1
LeftMouseDownAction=C:\Windows\nircmd.exe sendkeypress ctrl+s
[Square7]
Meter=Image
SolidColor=0,0,0,1
H=12; 23
w=12; 40
x=520
y=0
HideOnMouseOver=0
FadeDuration=0
AlphaValue=1
C:\Windows\nircmd.exe sendkeypress ctrl+s
AIDA64 sensor panel requires the use of two seperate individual key presses one to open it and one to close it (no built in toggle) so I'm using ctrl+s to open it and ctrl+c to close it.
I have looked at tutorals on this site, variables and toggles, as well as google research but I still have no idea. So all I would like to do is have the icon (image) toggle the opening and closing of the sensor panel.
If anyone could help it would be much appreciated, thank you for reading.
It is currently March 29th, 2024, 1:39 pm
How to make an icon toggle?
-
- Posts: 6
- Joined: October 7th, 2019, 5:47 pm
-
- Rainmeter Sage
- Posts: 5384
- Joined: April 12th, 2012, 9:40 pm
- Location: Cedar Point, Ohio, USA
Re: How to make an icon toggle?
One way to use the same image meter to perform 2 different actions is to create an ACTION variable, which you then toggle the value between 1 and 0. Use that variable as a nested portion of 2 new variables that contain the actual desired toggle action. See: Nested Variables
I added DynamicVariables=1 so changes to the ACTION variable are detected.
I changed the bang to LeftMouseUpAction so dragging is not hampered.
When the key up is detected, the bang will toggle the value of the ACTION variable from 0 to 1, have NirCmd send the keypress that reflect Action1 variable, and send a message to the log telling you what keys were sent. The next time the key is pressed and released, the ACTION variable will be toggled from 1 to 0, and NirCmd will send the Action0 variable. Each key press will toggle the value of ACTION and alternate the value of the variable used in the NirCmd.
Code: Select all
[Variables]
Action=0
Action0=ctrl+c
Action1=ctrl+s
[App7]
Meter=Image
ImageName=Temp.png
w=18
h=18
X=1340
Y=3
HideOnMouseOver=0
FadeDuration=0
AlphaValue=1
LeftMouseUpAction=[!SetVariable Action (1-#Action#)][C:\Windows\nircmd.exe sendkeypress [#Action[#Action]]][!Log "[#Action[#Action]]"]
DynamicVariables=1
I changed the bang to LeftMouseUpAction so dragging is not hampered.
When the key up is detected, the bang will toggle the value of the ACTION variable from 0 to 1, have NirCmd send the keypress that reflect Action1 variable, and send a message to the log telling you what keys were sent. The next time the key is pressed and released, the ACTION variable will be toggled from 1 to 0, and NirCmd will send the Action0 variable. Each key press will toggle the value of ACTION and alternate the value of the variable used in the NirCmd.
:: My DA Gallery :: Rainmeter DA Gallery :: Rainmeter Workshops :: Rainmeter Documentation :: BBCode Guide ::
-
- Posts: 6
- Joined: October 7th, 2019, 5:47 pm
Re: How to make an icon toggle?
Thank you so much eclectic-tec, I copied your Action variable and pasted so it now looks like this :
Nothing changed though I can still only open the panel and not close it, toggle didn't work.
Code: Select all
[Variables]
Action=0
Action0=ctrl+c
Action1=ctrl+s
[App7]
Meter=Image
ImageName=Temp.png
w=18
h=18
X=1340
Y=3
HideOnMouseOver=0
FadeDuration=0
AlphaValue=1
LeftMouseUpAction=[!SetVariable Action (1-#Action#)][C:\Windows\nircmd.exe sendkeypress [#Action[#Action]]][!Log "[#Action[#Action]]"]
DynamicVariables=1
[Square7]
Meter=Image
SolidColor=0,0,0,1
H=12; 23
w=12; 40
x=520
y=0
HideOnMouseOver=0
FadeDuration=0
AlphaValue=1
LeftMouseUpAction=[!SetVariable Action (1-#Action#)][C:\Windows\nircmd.exe sendkeypress [#Action[#Action]]][!Log "[#Action[#Action]]"]
DynamicVariables=1
Last edited by balala on October 7th, 2019, 8:34 pm, edited 1 time in total.
Reason: Please use <code> tags whenever are you posting code snippets. It's the </> button.
Reason: Please use <code> tags whenever are you posting code snippets. It's the </> button.
-
- Rainmeter Sage
- Posts: 16110
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: How to make an icon toggle?
Or beside eclectic-tech's very good solution (as usual), I'd propose another as well. This time I'd use the same Action variable as he did, would toggle it's value same way as he did, but based on its value, I'd perform the appropriate action. This is what I ment:
When you click the [App7] meter, the value of the Action variable toggles between 0 and 1. Depending on its current value, one of the IfTrueAction / IfFalseAction options is executed, one opening and the other closing the app.
Just one single concern I have: I'm not sure this way this method does work, because I suppose maybe a RunCommand plugin measure would be needed, to get the commands to properly work. If the above or eclectic-tech's code doesn't work (if any does, the other probably also does), please let us know, to can add the mentioned RunCommand plugin measure.
Code: Select all
[Variables]
Action=0
[MeasureAction]
Measure=Calc
Formula=#Action#
IfCondition=(#CURRENTSECTION#=0)
IfTrueAction=["C:\Windows\nircmd.exe" "sendkeypress" "ctrl+s"]
IfFalseAction=["C:\Windows\nircmd.exe" "sendkeypress" "ctrl+c"]
DynamicVariables=1
[App7]
Meter=Image
ImageName=Temp.png
w=18
h=18
X=1340
Y=3
HideOnMouseOver=0
FadeDuration=0
AlphaValue=1
LeftMouseUpAction=[!SetVariable Action "(1-#Action#)"][!UpdateMeasure "MeasureAction"]
DynamicVariables=1
Just one single concern I have: I'm not sure this way this method does work, because I suppose maybe a RunCommand plugin measure would be needed, to get the commands to properly work. If the above or eclectic-tech's code doesn't work (if any does, the other probably also does), please let us know, to can add the mentioned RunCommand plugin measure.
-
- Posts: 6
- Joined: October 7th, 2019, 5:47 pm
Re: How to make an icon toggle?
Thank you balala,
With your proposed solution I can now close the panel using the icon but only after I first refresh the skin. Now I can't open the panel using the icon as I could with eclectic-tec's way.
With your proposed solution I can now close the panel using the icon but only after I first refresh the skin. Now I can't open the panel using the icon as I could with eclectic-tec's way.
-
- Posts: 908
- Joined: December 30th, 2015, 9:47 am
Re: How to make an icon toggle?
Hi all.
Just out of my curiosity, Not a suggestion about OP's issue, sorry.
I couldn't find these as meter options. These three options are for skin section in Rainmeter.ini? (also set from Manage Rainmeter GUI)
Are they valid when described in meter setion?
Just out of my curiosity, Not a suggestion about OP's issue, sorry.
Code: Select all
HideOnMouseOver=0
FadeDuration=0
AlphaValue=1
Are they valid when described in meter setion?
-
- Rainmeter Sage
- Posts: 5384
- Joined: April 12th, 2012, 9:40 pm
- Location: Cedar Point, Ohio, USA
Re: How to make an icon toggle?
I thought your request was to have the same icon image "Temp.png" in the [App7] section send 'ctrl+s' when first pressed, then send 'ctrl+c' the next time it is pressed. My code using only [App7] will do that. You have a separate meter [Square7] section was not taking any action and is not needed or used in my suggestion.rainwelt wrote: ↑October 7th, 2019, 8:17 pm Thank you so much eclectic-tec, I copied your Action variable and pasted so it now looks like this :
Nothing changed though I can still only open the panel and not close it, toggle didn't work.Code: Select all
[Variables] Action=0 Action0=ctrl+c Action1=ctrl+s [App7] Meter=Image ImageName=Temp.png w=18 h=18 X=1340 Y=3 HideOnMouseOver=0 FadeDuration=0 AlphaValue=1 LeftMouseUpAction=[!SetVariable Action (1-#Action#)][C:\Windows\nircmd.exe sendkeypress [#Action[#Action]]][!Log "[#Action[#Action]]"] DynamicVariables=1 [Square7] Meter=Image SolidColor=0,0,0,1 H=12; 23 w=12; 40 x=520 y=0 HideOnMouseOver=0 FadeDuration=0 AlphaValue=1 LeftMouseUpAction=[!SetVariable Action (1-#Action#)][C:\Windows\nircmd.exe sendkeypress [#Action[#Action]]][!Log "[#Action[#Action]]"] DynamicVariables=1
If you want the [App7] section action to open the app and the [Square7] section action to close it, then you do not need my suggestion at all; simply add a mouse action to the [Square7] section.
Code: Select all
[App7]
Meter=Image
ImageName=Temp.png
w=18
h=18
X=1340
Y=3
; HideOnMouseOver=0
; FadeDuration=0
AlphaValue=255
LeftMouseUpAction=[C:\Windows\nircmd.exe sendkeypress ctrl+s]
[Square7]
Meter=Image
SolidColor=0,0,0,1
H=12
; 23
w=12
; 40
x=520
y=0
; HideOnMouseOver=0
; FadeDuration=0
; AlphaValue=1
LeftMouseUpAction=[C:\Windows\nircmd.exe sendkeypress ctrl+c]
I changed the alpha value of [App7] to 255 so the image will show.
I moved the commented values for W & H in [Square7] to separate lines.
I commented out invalid lines for "FadeDuration" and "HideOnMouseOver"; those are options for the entire skin and only are used in the [Rainmeter] section.
The alpha for [Square7] is set by the "SolidColor=0,0,0,1" option, so "AlphaValue=1" is also commented out.
Let us know if any of this works for you.
:: My DA Gallery :: Rainmeter DA Gallery :: Rainmeter Workshops :: Rainmeter Documentation :: BBCode Guide ::
-
- Posts: 6
- Joined: October 7th, 2019, 5:47 pm
Re: How to make an icon toggle?
Thank you guys,
Yes eclectic-tech when you posted your first suggestion I wasn't sure about the need for Square7 in the scenario so I removed that after it didn't work, and only used the code you provided for App7 which also didn't work. Did same thing with balala's suggestion (with and without Square7) just won't toggle.
I don't want to be a pain in the proverbial so I've settled on two icons one to open and one to close the panel which is workable enough, this is the code now.
Thank you guys for your help.
Yes eclectic-tech when you posted your first suggestion I wasn't sure about the need for Square7 in the scenario so I removed that after it didn't work, and only used the code you provided for App7 which also didn't work. Did same thing with balala's suggestion (with and without Square7) just won't toggle.
I don't want to be a pain in the proverbial so I've settled on two icons one to open and one to close the panel which is workable enough, this is the code now.
Code: Select all
[app6]
Meter=Image
ImageName=TempClose2.png
w=20
h=18
X=1098
Y=3
HideOnMouseOver=0
FadeDuration=0
AlphaValue=1
LeftMouseDownAction=C:\Windows\nircmd.exe sendkeypress ctrl+c
[Square6]
Meter=Image
SolidColor=0,0,0,1
H=23
w=40
x=520
y=0
HideOnMouseOver=0
FadeDuration=0
AlphaValue=1
C:\Windows\nircmd.exe sendkeypress ctrl+c
[App7]
Meter=Image
ImageName=TempOpen2.png
w=20
h=18
X=1338
Y=3
HideOnMouseOver=0
FadeDuration=1
AlphaValue=255
LeftMouseDownAction=C:\Windows\nircmd.exe sendkeypress ctrl+s
Last edited by balala on October 9th, 2019, 12:12 pm, edited 1 time in total.
Reason: Agian, please use <code> tags whenever are you posting code snippets. It's the </> button.
Reason: Agian, please use <code> tags whenever are you posting code snippets. It's the </> button.
-
- Rainmeter Sage
- Posts: 5384
- Joined: April 12th, 2012, 9:40 pm
- Location: Cedar Point, Ohio, USA
Re: How to make an icon toggle?
Balala's suggestion (or mine) will send the key commands via NirCmd, I can only think that the skin was being refreshed, or not updated, that cause them not to work for you.
Good to find you got a workable solution.
Good to find you got a workable solution.
:: My DA Gallery :: Rainmeter DA Gallery :: Rainmeter Workshops :: Rainmeter Documentation :: BBCode Guide ::
-
- Rainmeter Sage
- Posts: 16110
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: How to make an icon toggle?
You can now create a workaround to have only one button visible at a time, not both. Interested?