It is currently March 29th, 2024, 2:36 pm

HotKey plugin 1.0

Plugins and Addons popular with the Community
User avatar
Jax
Posts: 104
Joined: June 7th, 2021, 11:46 am

Re: HotKey plugin 1.0

Post by Jax »

That actually did what I wanted! Thanks, had no idea I'll have to specify L/R :thumbup:
Devo
Posts: 8
Joined: May 1st, 2020, 8:17 pm

Re: HotKey plugin 1.0

Post by Devo »

I'm trying to figure out how to perform certain hotkey actions if conditions are met, but I'm struggling with the logic of how to get this to work. I feel like I need to put the IfCondition within the HotKey action but I'm not sure how to do it since I have to specify a KeyDownAction instead of an IfTrueAction. I know the code below isn't going to work since I'm mixing IfConditions and KeyDownAction, but I'm trying to get something like this to work. Any help would be appreciated.

Code: Select all

[HideSkins]
Measure=Plugin
Plugin=HotKey
HotKey=#HideKey#
IfCondition=MeasurePlayPause = 2
KeyDownAction=[!RainmeterHide *][!CommandMeasure "MeasureMedia" "PlayPause"][!CommandMeasure "MeasureMedia" "VolumeMute"]
IfCondition2=MeasurePlayPause <> 2
KeyDownAction2=[!RainmeterHide *][!CommandMeasure "MeasureMedia" "VolumeMute"]
User avatar
death.crafter
Rainmeter Sage
Posts: 1399
Joined: April 24th, 2021, 8:13 pm

Re: HotKey plugin 1.0

Post by death.crafter »

Devo wrote: October 15th, 2021, 8:26 pm I'm trying to figure out how to perform certain hotkey actions if conditions are met, but I'm struggling with the logic of how to get this to work. I feel like I need to put the IfCondition within the HotKey action but I'm not sure how to do it since I have to specify a KeyDownAction instead of an IfTrueAction. I know the code below isn't going to work since I'm mixing IfConditions and KeyDownAction, but I'm trying to get something like this to work. Any help would be appreciated.

Code: Select all

[HideSkins]
Measure=Plugin
Plugin=HotKey
HotKey=#HideKey#
IfCondition=MeasurePlayPause = 2
KeyDownAction=[!RainmeterHide *][!CommandMeasure "MeasureMedia" "PlayPause"][!CommandMeasure "MeasureMedia" "VolumeMute"]
IfCondition2=MeasurePlayPause <> 2
KeyDownAction2=[!RainmeterHide *][!CommandMeasure "MeasureMedia" "VolumeMute"]
Ahh no it doesn't work like this. But in the meanwhile you can do something like

Code: Select all

[Variables]
...
HideSkins0=[!Hide][!CommandMeasure MeasureMedia PlayPause][!CommandMeasure MeasureMedia VolumeMute]
HideSkins1=[!Hide][!CommandMeasure MeasureMedia VolumeMute]

[IsPlaying]
Measure=Calc
Formula=MeasurePlayPause <> 2

[HideSkins]
Measure=Plugin
Plugin=HotKey
HotKey=#HideKey#
KeyDownAction=[#HideSkins[&IsPlaying]]
Reference: https://docs.rainmeter.net/manual/variables/nesting-variables/
from the Realm of Death
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: HotKey plugin 1.0

Post by balala »

Devo wrote: October 15th, 2021, 8:26 pm I'm trying to figure out how to perform certain hotkey actions if conditions are met, but I'm struggling with the logic of how to get this to work. I feel like I need to put the IfCondition within the HotKey action but I'm not sure how to do it since I have to specify a KeyDownAction instead of an IfTrueAction. I know the code below isn't going to work since I'm mixing IfConditions and KeyDownAction, but I'm trying to get something like this to work. Any help would be appreciated.
Not sure at all what would you like to achieve. Do you want to perform different actions on keystroke depending if the condition is true or false? This is what I figured out, but please let me know if I am right.
Devo
Posts: 8
Joined: May 1st, 2020, 8:17 pm

Re: HotKey plugin 1.0

Post by Devo »

balala wrote: October 16th, 2021, 7:35 pm
Not sure at all what would you like to achieve. Do you want to perform different actions on keystroke depending if the condition is true or false? This is what I figured out, but please let me know if I am right.
That's correct. @death.crafter's solution works, but I'm wondering if there's a more elegant(?) or simpler solution.
User avatar
death.crafter
Rainmeter Sage
Posts: 1399
Joined: April 24th, 2021, 8:13 pm

Re: HotKey plugin 1.0

Post by death.crafter »

Devo wrote: October 19th, 2021, 3:27 pm That's correct. @death.crafter's solution works, but I'm wondering if there's a more elegant(?) or simpler solution.
I am afraid no :(
from the Realm of Death
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: HotKey plugin 1.0

Post by balala »

Devo wrote: October 19th, 2021, 3:27 pm That's correct. @death.crafter's solution works, but I'm wondering if there's a more elegant(?) or simpler solution.
A set of IfConditions might be added to the [MeasurePlayPause] measure, to set different operations to the KeyDownAction option, depending on the state of the condition. This is more or less the same as death.crafter's solution, however not entirely. If you are interested but don't know how to achieve it, please let me know, to post a sample.
Devo
Posts: 8
Joined: May 1st, 2020, 8:17 pm

Re: HotKey plugin 1.0

Post by Devo »

balala wrote: October 19th, 2021, 5:27 pm A set of IfConditions might be added to the [MeasurePlayPause] measure, to set different operations to the KeyDownAction option, depending on the state of the condition. This is more or less the same as death.crafter's solution, however not entirely. If you are interested but don't know how to achieve it, please let me know, to post a sample.
I would appreciate an example. I've been modifying skins over the years off an on, but this is the first time I've tried to create something from scratch for my specific use case. Your posts have helped me over the years, so I appreciate this and everything else you've posted.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: HotKey plugin 1.0

Post by balala »

Devo wrote: October 19th, 2021, 5:32 pm I would appreciate an example. I've been modifying skins over the years off an on, but this is the first time I've tried to create something from scratch for my specific use case. Your posts have helped me over the years, so I appreciate this and everything else you've posted.
Ok, here is it. Add the IfCondition / IfTrueAction / IfFalseAction options to the [MeasurePlayPause] measure, without modifying it otherwise. The two !SetOption bangs will set the appropriate KeyDownAction option to the [HideSkins] measure:

Code: Select all

[MeasurePlayPause]
...
IfCondition=(MeasurePlayPause=2)
IfTrueAction=[!SetOption HideSkins KeyDownAction """[!Hide *][!CommandMeasure "MeasureMedia" "PlayPause"][!CommandMeasure "MeasureMedia" "VolumeMute"]"""][!UpdateMeasure "HideSkins"]
IfFalseAction=[!SetOption HideSkins KeyDownAction """[!Hide *][!CommandMeasure "MeasureMedia" "VolumeMute"]"""][!UpdateMeasure "HideSkins"]
Additionally you can freely remove the KeyDownAction option of the [HideSkins] measure, because this option is now set dynamically by one of the above !SetOption bangs, so there is no need to have it explicitly set on the measure. It's not a problem is you leave it there, but it's completely useless, because on refresh of the skin, it is anyway set by one of the above bangs.
death.crafter wrote: October 15th, 2021, 9:13 pm

Code: Select all

[Variables]
...
HideSkins0=[!Hide][!CommandMeasure MeasureMedia PlayPause][!CommandMeasure MeasureMedia VolumeMute]
HideSkins1=[!Hide][!CommandMeasure MeasureMedia VolumeMute]

[IsPlaying]
Measure=Calc
Formula=MeasurePlayPause <> 2

[HideSkins]
Measure=Plugin
Plugin=HotKey
HotKey=#HideKey#
KeyDownAction=[#HideSkins[&IsPlaying]]
Take care that the !Hide (used by you above) and the !Hide * (used by Devo, in the !RainmeterHide * form), perform different actions. First is hiding the current skin, while the last is hiding ALL activated skins.
User avatar
death.crafter
Rainmeter Sage
Posts: 1399
Joined: April 24th, 2021, 8:13 pm

Re: HotKey plugin 1.0

Post by death.crafter »

balala wrote: October 19th, 2021, 5:50 pm Take care that the !Hide (used by you above) and the !Hide * (used by Devo, in the !RainmeterHide * form), perform different actions. First is hiding the current skin, while the last is hiding ALL activated skins.
Ahh right, didn't notice. Thanks for letting me know!
from the Realm of Death