It is currently October 14th, 2024, 9:40 pm

HotKey plugin 1.0

Plugins and Addons popular with the Community
lmiol
Posts: 18
Joined: April 6th, 2022, 5:36 pm

Re: HotKey plugin 1.0

Post by lmiol »

balala wrote: November 12th, 2022, 10:04 pm Please double check your code and post it as you have it if it's working, because I assume there is something wrong in this post if the Plugin measure is working.
Yeah it wrong, but is works.
Probably part of code should be like this:

Code: Select all

[Rainmeter]
BackgroundMode=1
Update=-1
OnUpdateAction=[!Draggable 0][!ZPos -2][!SetWindowPosition "50%" "50%" "50%" "50%"]

[Variables]
KeyA=0x0D

[Launcher2]
Measure=Plugin
Plugin=HotKey
HotKey=#KeyA#
KeyUpAction=!Execute ["C:\Program Files (x86)\Steam\Steam.exe"]
User avatar
balala
Rainmeter Sage
Posts: 16658
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: HotKey plugin 1.0

Post by balala »

lmiol wrote: November 12th, 2022, 10:34 pm Yeah it wrong, but is works.
Probably part of code should be like this:

Code: Select all

[Rainmeter]
BackgroundMode=1
Update=-1
OnUpdateAction=[!Draggable 0][!ZPos -2][!SetWindowPosition "50%" "50%" "50%" "50%"]

[Variables]
KeyA=0x0D

[Launcher2]
Measure=Plugin
Plugin=HotKey
HotKey=#KeyA#
KeyUpAction=!Execute ["C:\Program Files (x86)\Steam\Steam.exe"]
Unfortunately, if the skin is active, the set action is executed whenever are you hitting the key, no matter if the skin has or has no focus. See below a solution.
The solution is to pause the HotKey plugin measure with a [!CommandMeasure "Launcher2" "Stop"] and unpause with a [!CommandMeasure "Launcher2" "Start"] bang. For instance, to enable the HotKey measure execution when you're hovering the mouse over the skin add a variable (let1s name it Action) to the [Variables] section:

Code: Select all

[Variables]
Action=0
Then add the following measure to your code:

Code: Select all

[MeasureHotKey]
Measure=Calc
Formula=#Action#
IfCondition=(#CURRENTSECTION#=0)
IfTrueAction=[!CommandMeasure "Launcher2" "Stop"]
IfFalseAction=[!CommandMeasure "Launcher2" "Start"]
DynamicVariables=1
And finally add the following two options to the [Rainmeter] section:

Code: Select all

[Rainmeter]
...
MouseOverAction=[!SetVariable Action "1"][!UpdateMeasure "MeasureHotKey"]
MouseLeaveAction=[!SetVariable Action "0"][!UpdateMeasure "MeasureHotKey"]
If the [Rainmeter] section already has MouseOverAction and MouseLeaveAction options, add the above bangs to the appropriate options, in addition to the existing ones.
With this solution, you get executed the set action ONLY when you're hovering the mouse over the skin.

Additional tip (once again): See the additional tip here. The !Execute bang should be omitted, no need for it, because it's deprecated. Accordingly the KeyUpAction option of the [Launcher2] measure, instead of KeyUpAction=!Execute ["C:\Program Files (x86)\Steam\Steam.exe"] should be simply KeyUpAction=["C:\Program Files (x86)\Steam\Steam.exe"].
lmiol
Posts: 18
Joined: April 6th, 2022, 5:36 pm

Re: HotKey plugin 1.0

Post by lmiol »

balala wrote: November 13th, 2022, 7:32 pm
Code works, as expected! Very Apretiated

But now i trying to get work #HotkeyA# (previous #Launcher2#) to all Green area instead of Red
Image

actually i am trying to get work #HotkeyA# of entire screen but only if taskbar is hided.
Rainmeter and this skin is intended as default shell instead Explorer. Hotkeys can enable/kill Explorer.
And if Explorer killed - then hotkeyA (button A of controller) should work at any area
Unfortunally this part

Code: Select all

["C:\Windows\SysWOW64\rundll32.exe" user32.dll,SetCursorPos 0,0"]
is forced solution to move cursor from center of screen.
Cursor at center of screen is a bug of Steam and it very annoying if you have 2 accounts
You do not have the required permissions to view the files attached to this post.
User avatar
balala
Rainmeter Sage
Posts: 16658
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: HotKey plugin 1.0

Post by balala »

lmiol wrote: November 15th, 2022, 12:44 am actually i am trying to get work #HotkeyA# of entire screen but only if taskbar is hided.
Rainmeter and this skin is intended as default shell instead Explorer. Hotkeys can enable/kill Explorer.
And if Explorer killed - then hotkeyA (button A of controller) should work at any area
Unfortunally this part

Code: Select all

["C:\Windows\SysWOW64\rundll32.exe" user32.dll,SetCursorPos 0,0"]
is forced solution to move cursor from center of screen.
Cursor at center of screen is a bug of Steam and it very annoying if you have 2 accounts
I don't entirely follow, however for first please try adding the following Padding option to the [Button] meter: Padding=((#WORKAREAWIDTH#-233)/2),((#WORKAREAHEIGHT#-233)/2),((#WORKAREAWIDTH#-233)/2),((#WORKAREAHEIGHT#-233)/2). This is working if you set the width and height of the [Button] meter both to 233. You have the following options on the meter: W=233% and H=233%. Am not sure what you meant by using the percent character in these options, however they both have to be expressed in pixels, can't set them to percent. That's why I assumed both should be set to 233. If you want to change them, make sure you change the appropriate values in the above Padding option as well.
lmiol
Posts: 18
Joined: April 6th, 2022, 5:36 pm

Re: HotKey plugin 1.0

Post by lmiol »

balala wrote: November 15th, 2022, 6:56 pm I don't entirely follow, however for first please try adding the following Padding option to the [Button] meter: Padding=((#WORKAREAWIDTH#-233)/2),((#WORKAREAHEIGHT#-233)/2),((#WORKAREAWIDTH#-233)/2),((#WORKAREAHEIGHT#-233)/2). This is working if you set the width and height of the [Button] meter both to 233. You have the following options on the meter: W=233% and H=233%. Am not sure what you meant by using the percent character in these options, however they both have to be expressed in pixels, can't set them to percent. That's why I assumed both should be set to 233. If you want to change them, make sure you change the appropriate values in the above Padding option as well.
hi, sorry for long respond.
Yeah i got it
Padding=((#WORKAREAWIDTH#-233)/2),((#WORKAREAHEIGHT#-233)/2),((#WORKAREAWIDTH#-233)/2),((#WORKAREAHEIGHT#-233)/2)
this one is for dynamic size of button.

but i still didnt find solution for HOTKEY for entire WORKAREA

it seems here

Code: Select all

[MeasureHotKey]
Measure=Calc
Formula=#Action#
IfCondition=(#CURRENTSECTION#=0)
IfTrueAction=[!CommandMeasure "HotkeyA" "Stop"]
IfFalseAction=[!CommandMeasure "HotkeyA" "Start"]
DynamicVariables=1
should be changed condition IfCondition=(#CURRENTSECTION#=0)
how to write code for "Please work for #CURRENTSECTION#=0 && for entire screen" ?
User avatar
balala
Rainmeter Sage
Posts: 16658
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: HotKey plugin 1.0

Post by balala »

lmiol wrote: May 8th, 2023, 12:55 pm but i still didnt find solution for HOTKEY for entire WORKAREA
Yeah, long time has gone on (half a year), so I have to remember exactly what have we worked on. So, please tell me what do you mean by "HOTKEY for entire WORKAREA"?

Additional note: if you check the "Notify me when a reply is posted" checkbox below the filed in which you're writing your reply, you'll get a notification by email when a reply is posted in the topic. I assume you haven't check this checkbox and you've forgot to come back and check if a reply has been posted in the topic. Checking the above checkbox, can help you to avoid forgetting this.
lmiol
Posts: 18
Joined: April 6th, 2022, 5:36 pm

Re: HotKey plugin 1.0

Post by lmiol »

balala wrote: May 8th, 2023, 3:20 pm Yeah, long time has gone on (half a year), so I have to remember exactly what have we worked on. So, please tell me what do you mean by "HOTKEY for entire WORKAREA"?
this code

Code: Select all

[MeasureHotKey]
Measure=Calc
Formula=#Action#
IfCondition=(#CURRENTSECTION#=0)
IfTrueAction=[!CommandMeasure "HotkeyA" "Stop"]
IfFalseAction=[!CommandMeasure "HotkeyA" "Start"]
DynamicVariables=1
works only if i do mouseover to Steam button

this code you suggest me before because my hotkey was work everywhere outside widget.
but i need HotkeyA works only when mouse is on desktop. So you did for me
IfCondition=(#CURRENTSECTION#=0)
and your code works, but only in RED area
Image
i trying do HotkeyA to work of whole GREEN area only while mouse on widget
Maybe you know some tricks?
balala wrote: May 8th, 2023, 3:20 pm Additional note: if you check the "Notify me when a reply is posted" checkbox below the filed in which you're writing your reply, you'll get a notification by email when a reply is posted in the topic. I assume you haven't check this checkbox and you've forgot to come back and check if a reply has been posted in the topic. Checking the above checkbox, can help you to avoid forgetting this.
Sorry, iwas at hospital few month, then i forgot about this =(
User avatar
balala
Rainmeter Sage
Posts: 16658
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: HotKey plugin 1.0

Post by balala »

lmiol wrote: May 8th, 2023, 4:30 pm but i need HotkeyA works only when mouse is on desktop. So you did for me
Didn't check now, but the Steam button has to have a MouseOverAction and a MouseLeaveAction like the following ones:

Code: Select all

[Steam]
...
MouseOverAction=[!SetVariable Action "1"][!UpdateMeasure "MeasureHotKey"]
MouseLeaveAction=[!SetVariable Action "0"][!UpdateMeasure "MeasureHotKey"]
These are the options which set the proper value for the Action variable, setting it to 1 when you're hovering the mouse over the (in this case) button and to 0 when you're leaving it. To get it working as you want, you have to modify the code in a way to get the Action variable set to 1 when the mouse is over the elemnet you want and 0 otherwise. But I'm not entirely sure I understand what do you mean by "when mouse is on desktop". Do you want to get the hotkey working when you let all skins and got the mouse on the desktop? If this is what you want, it's a little bit more complicated, because I don't know how could you detect when is the mouse over the desktop.
lmiol wrote: May 8th, 2023, 4:30 pm Sorry, iwas at hospital few month, then i forgot about this =(
Sorry about this. Wish you health.
I just assumed you've just forgot and this is why you didn't come back for so long and this is why I posted my suggestion.
lmiol
Posts: 18
Joined: April 6th, 2022, 5:36 pm

Re: HotKey plugin 1.0

Post by lmiol »

balala wrote: May 8th, 2023, 7:04 pm But I'm not entirely sure I understand what do you mean by "when mouse is on desktop". Do you want to get the hotkey working when you let all skins and got the mouse on the desktop? If this is what you want, it's a little bit more complicated, because I don't know how could you detect when is the mouse over the desktop.

Sorry about this. Wish you health.
I just assumed you've just forgot and this is why you didn't come back for so long and this is why I posted my suggestion.
English is not my native language. and I am now trying to find words to describe the situation as best as possible.

I don't know if you will be interested in reading all this, but the concept of the whole widget is this:
The computer starts up. automatically launches Rainmeter, which is configured instead of the default Explorer app.
After starting Rainmeter, a Steam button appears on the desktop, which, when pressed, launches the Steam application
There are 3 hotkeys through Rainmeter
CTRL+WIN+E to launch Explorer
CTRL+WIN+W to turn off Explorer
And the button from the XBOX gamepad A, which in this case fully corresponds to the virtual Return button (0x0D), because I have already set up the work on the gamepad separately.
It turns out that Gamepad button A = Keyboard Return
This Return button should work when the desktop is open, but hovering over the Steam button is optional. But if any other window of any program is open, then the Return button should not launch Steam.
All this is done so that after starting Windows and press A on the gamepad, Steam will start successfully, even if the mouse cursor was not hovered over the Steam button

Right now hotkey A only works if I hover over the button, which creates a number of ease-of-use difficulties of its own.

It seems to me that some additional and somehow invisible layer is needed here, which would fill the entire desktop, and if the mouse cursor is outside the Steam button, but on this layer - then HotkeyA (Return) will work according to the plan - it will launch Steam = )

Sorry for that wall of text =(
Regards
User avatar
Yincognito
Rainmeter Sage
Posts: 8465
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: HotKey plugin 1.0

Post by Yincognito »

lmiol wrote: May 8th, 2023, 10:49 pm Right now hotkey A only works if I hover over the button, which creates a number of ease-of-use difficulties of its own.

It seems to me that some additional and somehow invisible layer is needed here, which would fill the entire desktop, and if the mouse cursor is outside the Steam button, but on this layer - then HotkeyA (Return) will work according to the plan - it will launch Steam = )
For the record and from what I can tell from the codes provided, the padding that is added to the [Button] meter's image:

Code: Select all

Padding=((#WORKAREAWIDTH#-233)/2),((#WORKAREAHEIGHT#-233)/2),((#WORKAREAWIDTH#-233)/2),((#WORKAREAHEIGHT#-233)/2)
should, in fact, expand the skin area to the entire desktop, assuming that dynamic variables are enabled, the solid color with which the padding is drawn is not entirely transparent, AND the section where you change the Action variable supports dynamic variables (the [Rainmeter] section is NOT, with a few exceptions, so these changes can be moved to the meter itself). Based on your uploaded skin earlier (which may or may not be how your skin looks now), this code should do what you want:

Code: Select all

[Variables]
ButtonWidth=233
ButtonHeight=233
PATH=#@#App\
KeyA=0x0D
KeyCTRLWINE=0x11 0x5B 0x45
KeyCTRLWINW=0x11 0x5B 0x57
Action=0

[Rainmeter]
Update=-1
OnUpdateAction=[!Draggable 0][!ZPos -2][!SetWindowPosition "50%" "50%" "50%" "50%"]

[Metadata]
Author=lmiol
Name=Steam Button instead Explorer
Description=Steam Button Instead Explorer 
Version=0.0.1
License=Creative Commons BY-NC-SA 3.0

---Measures---

[MeasureKill]
Measure=Plugin
Plugin=RunCommand
Parameter=taskkill /F /IM explorer.exe
State=Hide
OutputType=ANSI

[HotkeyA]
Measure=Plugin
Plugin=HotKey
HotKey=#KeyA#
;KeyUpAction=["C:\Program Files (x86)\Steam\Steam.exe" "-gamepadui -skipinitialbootstrap -noverifyfiles -nobootstrapupdate -norepairfiles -overridepackageurl"] ["C:\Windows\SysWOW64\rundll32.exe" user32.dll,SetCursorPos 0 0"][!SetOption Button ImageName "#@#Images\button.png"][!UpdateMeter Button][PLAY "#PATH#activation.wav"][!Redraw]
;KeyUpAction=["C:\Program Files (x86)\Steam\Steam.exe" "-gamepadui"] ["C:\Windows\SysWOW64\rundll32.exe" user32.dll,SetCursorPos 0 0"][!SetOption Button ImageName "#@#Images\button.png"][!UpdateMeter Button][PLAY "#PATH#activation.wav"][!Redraw]
;KeyDownAction=[!SetOption Button ImageName "#@#Images\pressed.png"][!UpdateMeter Button][!Redraw]

[HotkeyCTRLWINE]
Measure=Plugin
Plugin=HotKey
HotKey=#KeyCTRLWINE#
;KeyUpAction=["C:\Windows\Explorer.exe"][PLAY "#PATH#activation.wav"][!Redraw]

[HotkeyCTRLWINW]
Measure=Plugin
Plugin=HotKey
HotKey=#KeyCTRLWINW#
;KeyUpAction=[!CommandMeasure MeasureKill "Run"][PLAY "#PATH#activation.wav"]

[MeasureHotKey]
Measure=Calc
Formula=#Action#
IfCondition=(#CURRENTSECTION#=0)
IfTrueAction=[!Log "Key Input Stopped"][!CommandMeasure "HotkeyA" "Stop"]
IfFalseAction=[!Log "Key Input Started"][!CommandMeasure "HotkeyA" "Start"]
DynamicVariables=1

---Meters---

[Button]
Meter=Image
ImageName=#@#Images\button.png
W=#ButtonWidth#
H=#ButtonHeight#
Padding=((#WORKAREAWIDTH#-#ButtonWidth#)/2),((#WORKAREAHEIGHT#-#ButtonHeight#)/2),((#WORKAREAWIDTH#-#ButtonWidth#)/2),((#WORKAREAHEIGHT#-#ButtonHeight#)/2)
SolidColor=0,0,0,1
MouseOverAction=[!SetVariable Action "1"][!UpdateMeasure "MeasureHotKey"][!SetOption #CURRENTSECTION# ImageName "#@#Images\hover.png"][!UpdateMeter #CURRENTSECTION#][!Redraw]
MouseLeaveAction=[!SetVariable Action "0"][!UpdateMeasure "MeasureHotKey"][!SetOption #CURRENTSECTION# ImageName "#@#Images\button.png"][!UpdateMeter #CURRENTSECTION#][!Redraw]
;LeftMouseUpAction=["C:\Program Files (x86)\Steam\Steam.exe" "-gamepadui -skipinitialbootstrap -noverifyfiles -nobootstrapupdate -norepairfiles -overridepackageurl"][PLAY "#PATH#activation.wav"]
;LeftMouseUpAction=["C:\Program Files (x86)\Steam\Steam.exe" "-gamepadui"][PLAY "#PATH#activation.wav"]
;LeftMouseDownAction=[!SetOption #CURRENTSECTION# ImageName "#@#Images\pressed.png"][!UpdateMeter #CURRENTSECTION#][!Redraw]
;RightMouseUpAction=[]
;RightMouseDownAction=[]
DynamicVariables=1
I commented out all the other key or mouse actions cause I don't want them triggered on my system and they're more or less irrelevant for the subject being discussed here - feel free to uncomment the needed ones or adjust them as desired afterwards. I also added two !Log bangs that will output to Rainmeter's log whether the key input is started or stopped, for conveniency - feel free to remove them once you watch the log and see that things happen like you want to. Setting the Action variable is moved to the [Button] meter, and also for conveniency, I added two variables from which you can easily control the width and height of the [Button] image so that you're not tied up to the 233 values anymore - you can adjust them from the [Variables] section.

P.S. As it is now, the button image is highlighted whenever the mouse is over the entire screen area belonging to the skin, with the exception of other foreground windows that might cover up the skin at some points, like you described. If you want the button image to be highlighted only when you're with the mouse over the said image (and not the entire desktop), you can easily make a blank rectangular Shape or Image meter as big as the desktop, acting as a background, remove the now obsolete padding from the button image, and distribute various bangs accordingly between the two meters:

Code: Select all

---Meters---

[Background]
Meter=Image
W=#WORKAREAWIDTH#
H=#WORKAREAHEIGHT#
SolidColor=0,0,0,1
MouseOverAction=[!SetVariable Action "1"][!UpdateMeasure "MeasureHotKey"]
MouseLeaveAction=[!SetVariable Action "0"][!UpdateMeasure "MeasureHotKey"]
DynamicVariables=1

[Button]
Meter=Image
ImageName=#@#Images\button.png
X=((#WORKAREAWIDTH#-#ButtonWidth#)/2)
Y=((#WORKAREAHEIGHT#-#ButtonHeight#)/2)
W=#ButtonWidth#
H=#ButtonHeight#
MouseOverAction=[!SetOption #CURRENTSECTION# ImageName "#@#Images\hover.png"][!UpdateMeter #CURRENTSECTION#][!Redraw]
MouseLeaveAction=[!SetOption #CURRENTSECTION# ImageName "#@#Images\button.png"][!UpdateMeter #CURRENTSECTION#][!Redraw]
;LeftMouseUpAction=["C:\Program Files (x86)\Steam\Steam.exe" "-gamepadui -skipinitialbootstrap -noverifyfiles -nobootstrapupdate -norepairfiles -overridepackageurl"][PLAY "#PATH#activation.wav"]
;LeftMouseUpAction=["C:\Program Files (x86)\Steam\Steam.exe" "-gamepadui"][PLAY "#PATH#activation.wav"]
;LeftMouseDownAction=[!SetOption #CURRENTSECTION# ImageName "#@#Images\pressed.png"][!UpdateMeter #CURRENTSECTION#][!Redraw]
;RightMouseUpAction=[]
;RightMouseDownAction=[]
DynamicVariables=1
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth