It is currently May 31st, 2020, 12:34 am

HotKey plugin 1.0

Plugins and Addons popular with the Community
copystring
Posts: 1
Joined: January 26th, 2020, 1:14 pm

Re: HotKey plugin 1.0

Post by copystring »

Hey, I'm trying to bind LCTRL+LALT+mouse wheel up /mouse wheel down.
This is not supported, right? Haven't found the key on the Microsoft site.
User avatar
balala
Rainmeter Sage
Posts: 10643
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: HotKey plugin 1.0

Post by balala »

copystring wrote:
January 26th, 2020, 1:16 pm
This is not supported, right?
Well, it is and it's not.
Here is what am i talking about: you can easily take an action when LCtrl and / or LAlt is pressed, however detecting the mouse wheel scroll, this is a little bit more difficult. Not completely impossible, but there is a limitation.
Here is a sample code, based on the code of the example skin (HotKey_1.0.0.12.rmskin) posted here:

Code: Select all

[Rainmeter]
Update=1000
BackgroundMode=2
SolidColor=#BackgroundColor#

[Variables]
BackgroundColor=50,50,50,255
Key1=LCTRL LALT
LCtrlAlt=0

[MeasureLCtrlLAlt]
Measure=Plugin
Plugin=HotKey
HotKey=#Key1#
KeyDownAction=[!SetVariable LCtrlAlt "1"][!UpdateMeasure "MeasureAction"]
KeyUpAction=[!SetVariable LCtrlAlt "0"][!SetVariable MouseScroll "0"][!UpdateMeasure "MeasureAction"]

[MeasureAction]
Measure=Calc
Formula=( #LCtrlAlt# * #MouseScroll# )
IfCondition=(#CURRENTSECTION#=0)
IfTrueAction=[!SetOption Background SolidColor "#BackgroundColor#"][!UpdateMeter Background][!Redraw]
IfFalseAction=[!SetOption Background SolidColor "255,0,0"][!UpdateMeter Background][!Redraw]
DynamicVariables=1

[Background]
Meter=Image
SolidColor=#BackgroundColor#
X=0
Y=0
W=200
H=90
MouseScrollUpAction=[!SetVariable MouseScroll "1"][!UpdateMeasure "MeasureAction"]
MouseScrollDownAction=[!SetVariable MouseScroll "1"][!UpdateMeasure "MeasureAction"]
This works, however
  • The mouse wheel scrolling is detected only when you're scrolling over the skin. Scrolling elsewhere is not detected.
  • The skin detects when you1re holding the appropriate keys and you're scrolling (in the same time), however if you scroll first over the skin and you press the LCtrl + LAlt later, the skin detects the action. After releasing the LCtrl + LAlt, the action isn't detected once again, even if you press the keys again.
Unfortunately me personally don't see a way to make exactly what have you described, better than this.
wladue613
Posts: 3
Joined: May 1st, 2020, 5:19 am

Re: HotKey plugin 1.0

Post by wladue613 »

I was curious how to toggle on/off a specific skin with a keypress (CTRL ALT L). I see how to shift between layouts and have used that as a workaround, but it's just to toggle on/off Rento\Song Info.

Is this difficult to do?
User avatar
balala
Rainmeter Sage
Posts: 10643
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: HotKey plugin 1.0

Post by balala »

wladue613 wrote:
May 1st, 2020, 5:22 am
I was curious how to toggle on/off a specific skin with a keypress (CTRL ALT L). I see how to shift between layouts and have used that as a workaround, but it's just to toggle on/off Rento\Song Info.

Is this difficult to do?
No, it can easily be done, however there is a question: what do you mean by toggle on/off a skin? Because it can be loaded / unloaded or shown / hidden on the keypress. If you load, then unload a skin, as it says, after the unload the skin is closed and doesn't run, but if you just hide it, it still runs, it's just not visible on the screen (as I hope you figured it out, the skin is hidden), but the measures are still working, for instance the Counter function still counts.
So here is a solution for the first case, when you want to load / unload the skin:

Code: Select all

[MeasureToggle]
Measure=Plugin
Plugin=HotKey
HotKey=CTRL ALT L
KeyDownAction=[!ToggleConfig "CONFIG" "INI-FILE.ini"]
Note that you have to replace the parameters of the !ToggleConfig bang with the appropriate names.
If on the other hand, you wanna just show / hide the skin, you have to replace the KeyDownAction option of the above measure with the following one: KeyDownAction=[!ToggleFade "CONFIG"]. Note that in this case the skin has to be loaded, the measure will just hide / show it. If the skin is not loaded, the above measure won't work, hitting the appropriate keys won't have any consequences, except some error messages in the log.
wladue613
Posts: 3
Joined: May 1st, 2020, 5:19 am

Re: HotKey plugin 1.0

Post by wladue613 »

Fantastic. Thank you so much for your help!
User avatar
balala
Rainmeter Sage
Posts: 10643
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: HotKey plugin 1.0

Post by balala »

wladue613 wrote:
May 1st, 2020, 8:19 pm
Fantastic. Thank you so much for your help!
I assume you've succeeded getting it to work, right?
wladue613
Posts: 3
Joined: May 1st, 2020, 5:19 am

Re: HotKey plugin 1.0

Post by wladue613 »

Yep. Worked great. Appreciate ya.
User avatar
balala
Rainmeter Sage
Posts: 10643
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: HotKey plugin 1.0

Post by balala »

wladue613 wrote:
May 1st, 2020, 9:36 pm
Yep. Worked great. Appreciate ya.