It is currently March 28th, 2024, 11:24 pm

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: 16110
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: 16110
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: 16110
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: 16110
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.
WirlyWirly
Posts: 17
Joined: July 15th, 2020, 6:37 am

Re: HotKey plugin 1.0

Post by WirlyWirly »

Curious if this plugin ever got support for only responding to hotkeys when the skin has focus.

I'd like to add hotkeys to my launcher so that I don't have to click the meter's icon to launch the corresponding program. However, I use lots of different hotkeys inside of vim and other programs, so I need it to only work when the skin has focus.

Something like this...

Code: Select all

[HotKey-Vim]
Measure = Plugin
Plugin = HotKey
HotKey = 1
KeyUpAction = $Trigger LeftMouseUpAction of 'MeterVim'

--- snip ---

[MeterVim]
Meter = Image
...
LeftMouseUpAction = ["#PROGRAMPATH#..\PortableGit\Vim-Wrapper.exe"]#skins_bottom#
Anyone know of a way to do this? I'm thinking I won't be able to trigger the LeftMouseUpAction directly, so I'll probably have to copy the action to the Hotkey block or assign it to a common variable.
User avatar
Alex88
Posts: 92
Joined: July 18th, 2020, 1:23 am
Location: California

Re: HotKey plugin 1.0

Post by Alex88 »

Can try this example using OnFocusAction= and OnUnfocusAction=.
Ignore the extraneous -1 Update or UpdateDivider if needed, am just used to placing that.

Code: Select all

[Rainmeter]
 Update=-1
 AccurateText=1
 DynamicWindowSize=1
 OnFocusAction=[!CommandMeasure measureHotkey Start][!SetOption MeterText FontColor 255,255,255][!UpdateMeter *][!Redraw]
 OnUnfocusAction=[!CommandMeasure measureHotkey Stop][!SetOption MeterText FontColor 128,128,128][!UpdateMeter *][!Redraw]

[measureHotkey]
 Measure=Plugin
 Plugin=Hotkey
 Hotkey=1
 ShowAllKeys=1
 KeyDownAction=[!SetOption MeterText SolidColor 0,100,0][!UpdateMeter *][!Redraw]
 KeyUpAction=[!SetOption MeterText SolidColor 0,0,0][!UpdateMeter *][!Redraw]
 UpdateDivider=-1

[MeterText]
 Meter=String
 FontSize=12
 StringAlign=CenterCenter
 FontColor=128,128,128
 SolidColor=0,0,0
 Text=Text

 X=50
 Y=25
 W=100
 H=50
HotkeyFocus.gif
You do not have the required permissions to view the files attached to this post.